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
functionmyValueArg(arg: "value"){}functionmyStringArg(arg: string){}namespacens{// Not needed, but shows it's not scope relatedletstr="value";if(str==="value"){myValueArg(str);[].forEach(()=>{myValueArg(str);// Argument of type 'string' is not assignable to parameter of type '"value"'.});}else{myStringArg(str);[].forEach(()=>{myStringArg(str);});}}
Expected behavior:
No warnings: the value (and type) of str has not changed.
Actual behavior:
Warning Argument of type 'string' is not assignable to parameter of type '"value"'.
The text was updated successfully, but these errors were encountered:
Use const. let bindings are reset because the function might be invoked asynchronously and a new value could be set to the let variable in the mean time.
That sort of makes sense (though this is just a sample, the real code I noticed it on is most definitely not a constant). Wouldn't it be better to annotate things that are definitely not asynchronous to prevent this spurious warning?
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
TypeScript Version: 2.2.1
Code
Expected behavior:
No warnings: the value (and type) of
str
has not changed.Actual behavior:
Warning
Argument of type 'string' is not assignable to parameter of type '"value"'.
The text was updated successfully, but these errors were encountered: