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
Duplicate of #11152 -- the problem is that annotating the result as OK<[string, number]> has no effect in the inferred type argument. let result = ok<[string, number]> (["hello", 12]); would work though.
This bug arises because ["hello", 12] is inferred as array (string | number)[] instead of tuple [string, number], so, to fix this bug the type inference algorithm must be situational.
Expected behavior:
No error
Actual behavior:
Type error.
Playground Link:
http://www.typescriptlang.org/play/#src=interface%20OK%3CT%3E%20%7B%0D%0A%20%20%20%20kind%3A%20%22OK%22%3B%0D%0A%20%20%20%20value%3A%20T%3B%0D%0A%7D%0D%0Aexport%20function%20ok%3CT%3E(value%3A%20T)%3A%20OK%3CT%3E%20%7B%0D%0A%20%20%20%20return%20%7B%0D%0A%20%20%20%20%20%20%20%20kind%3A%20%22OK%22%2C%0D%0A%20%20%20%20%20%20%20%20value%3A%20value%0D%0A%20%20%20%20%7D%3B%0D%0A%7D%0D%0A%0D%0Alet%20result%3A%20OK%3C%5Bstring%2C%20number%5D%3E%20%3D%20ok(%5B%22hello%22%2C%2012%5D)%3B
Related Issues:
The text was updated successfully, but these errors were encountered: