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 TypeScript definition for Array.filter specifies the callback must return a boolean, thus the code example at the bottom of this post fails to compile. Here's the current definition:
// the purpose is to weed out falsey valuesleta=[1,2,3,undefined,0,42,""].filter(i=>i)// "i => i" is an error because it does not return boolean// the following has no errorletb=[1,2,3,undefined,0,42,""].filter(i=>!!i)
Expected behavior:
No compile errors
Actual behavior:
Compile errors
The text was updated successfully, but these errors were encountered:
To reduce noise in issue searches, we close issues that are already tracked somewhere else. If you think the linked issue is not actually the same, please leave a comment here (we do read comments on closed issues). Otherwise you can follow or chime in on the linked issue. Thanks!
The TypeScript definition for Array.filter specifies the callback must return a boolean, thus the code example at the bottom of this post fails to compile. Here's the current definition:
The spec says this about the callback parameter:
Thus I propose the definition should be changed to:
Note: using a double not-operator is a sufficient workaround with negligible implications
TypeScript Version:
1.8.7
Code
Playground
Expected behavior:
No compile errors
Actual behavior:
Compile errors
The text was updated successfully, but these errors were encountered: