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
The inferred type of a tuple expression is an array, for example
constfoo=['hello',3,true]// foo: (string | number | boolean)[]
which is a pain when what you really wanted was a tuple; you need to give a type ascription in order to tell the compiler you meant it to be a tuple, e.g.
It seems like this is wholly unnecessary, because the type [string, number, boolean] is assignable to (string | number | boolean)[], and carries strictly more information. So the compiler is prematurely throwing away information, when it could just wait and see if later on the type needs to be specialized to an array.
The text was updated successfully, but these errors were encountered:
TypeScript Version: 2.1.4
The inferred type of a tuple expression is an array, for example
which is a pain when what you really wanted was a tuple; you need to give a type ascription in order to tell the compiler you meant it to be a tuple, e.g.
It seems like this is wholly unnecessary, because the type
[string, number, boolean]
is assignable to(string | number | boolean)[]
, and carries strictly more information. So the compiler is prematurely throwing away information, when it could just wait and see if later on the type needs to be specialized to an array.The text was updated successfully, but these errors were encountered: