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
Type '(number | I)[]' is not assignable to type 'I[]'.
Type 'number | I' is not assignable to type 'I'.
'number | I' is assignable to the constraint of type 'I', but 'I' could be instantiated with a different subtype of constraint '{}'.
Type 'number' is not assignable to type 'I'.
'number' is assignable to the constraint of type 'I', but 'I' could be instantiated with a different subtype of constraint '{}'.
By default array-literals are inferred as arrays, so you return an array that has either a number or a I. Changing this to automatically infer as tuples would very likely be a breaking change. And we already have a way to tell the compiler to infer it as a tuple: as const.
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow.
Search Terms: Generic, Heterogeneous Array
Code
Expected behavior: no error
Actual behavior: error
Playground Link: http://www.typescriptlang.org/play/#code/GYVwdgxgLglg9mABAZwBYmMANgUwIIBOBAhgJ4A8AkgHwAUxRZAXIpQNoC6AlC+x4gG8AUIkQEcUEASS0RoxAxKk58xADoAtsQAOtGFBwbEAXmqI2AWWJRUakmAAmcDbS4AaRPsPcV8tcjgCKFp6DwAjLhMzYjYABn4AWkQwuJ9VUU0dPQMjU08ctgBGNMQuAG4hAF8gA
P.S Flow works fine
The text was updated successfully, but these errors were encountered: