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
typeFoo='A'|'B';constfoo_list: Foo[]=['A','X'];// Error: Type '"X"' is not assignable to type 'Foo'declarefunctionbar(x: Foo[]);bar(['A','X']);// Error (x2): Type 'string' is not assignable to type 'Foo'
Expected behavior:
Same error on line 4 as on line 2
Actual behavior:
All elements of the array are highlighted as errors instead, making it difficult to spot which one is wrong.
Mild title gore, sorry.
TypeScript Version: 3.2.0-dev.201xxxxx
Search Terms: array union type error
Code
Expected behavior:
Same error on line 4 as on line 2
Actual behavior:
All elements of the array are highlighted as errors instead, making it difficult to spot which one is wrong.
Playground Link: http://www.typescriptlang.org/play/#src=type%20Foo%20%3D%20'A'%20%7C%20'B'%3B%0Aconst%20foo_list%3A%20Foo%5B%5D%20%3D%20%5B'A'%2C%20'X'%5D%3B%0Adeclare%20function%20bar(x%3A%20Foo%5B%5D)%3B%0Abar(%5B'A'%2C%20'X'%5D)%3B%0A
Related Issues: Probably #26077 or one of its constituents
The text was updated successfully, but these errors were encountered: