You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
declareconstx: 'a'[]|'b'[];x.forEach(v=>{});// FAIL// it doesn't work as is, so we have to resort// to enforcing the shape of the typeconstshape=<T>(t: T[]): T[]=>t;constx1=shape(x);// converts to ('a' | 'b')[]x1.forEach(v=>{});// OKdeclareconsty: 'a'[]|'b'[]|never[]y.forEach(v=>{});// FAILconsty1=shape(y);// cannot convert anymorey1.forEach(v=>{});// FAILdeclareconstz: 'a'[]|never[]z.forEach(v=>{});// OK. apparently 3 cases was too much
Expected behavior:
No error messages in either case.
Actual behavior:
Conversion of union of arrays to array of unions happens only if it's enforced manually, and only if there is no never[] cases.
TypeScript Version: 3.8.0-dev.20191121
Search Terms: array union
Code
Expected behavior:
No error messages in either case.
Actual behavior:
Conversion of union of arrays to array of unions happens only if it's enforced manually, and only if there is no
never[]
cases.Playground Link:
Link
The text was updated successfully, but these errors were encountered: