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
functionfoo(arg: number[]|string[]){arg.find(()=>false);// cannot invoke an expression whose type lacks a call signature}functionbar(arg: (number|string)[]){arg.find(()=>false);}
Expected behavior:
Inside foo, arg is always an array, either of numbers or of strings, so I expect the find method to be recognized by the compiler.
Actual behavior:
It doesn't recognize it, and it throws a cannot invoke an expression whose type lacks a call signature error.
I don't see any good reason why inside bar the compiler understands that arg is always an array, but not inside foo.
The text was updated successfully, but these errors were encountered:
TypeScript Version: 2.0.3
Code
Expected behavior:
Inside
foo
,arg
is always an array, either of numbers or of strings, so I expect thefind
method to be recognized by the compiler.Actual behavior:
It doesn't recognize it, and it throws a
cannot invoke an expression whose type lacks a call signature
error.I don't see any good reason why inside
bar
the compiler understands that arg is always an array, but not insidefoo
.The text was updated successfully, but these errors were encountered: