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
{{ message }}
Repository navigation
Inferred Type Predicates don't work with the Boolean function #58999
// Correctly infers type as stringconstworks: string[]=[...Array(5)].map(v=>{if(v%2===0){return'a string';}returnnull;}).filter(v=>!!v);// Doesn't work for some reason even though its basically the sameconstdoesntWork1: string[]=[...Array(5)].map(v=>{if(v%2===0){return'a string';}returnnull;}).filter(v=>v);// Cant infer Boolean workingconstdoesntWork2: string[]=[...Array(5)].map(v=>{if(v%2===0){return'a string';}returnnull;}).filter(Boolean);constdoesntWork3: string[]=[...Array(5)].map(v=>{if(v%2===0){return'a string';}returnnull;}).filter(v=>Boolean(v));
Activity
jakebailey commentedon Jun 24, 2024
Booleanis not a type predicate. See #50387 (comment) and #16655MichalMarsalek commentedon Jun 24, 2024
#57465 (comment)
jakeleventhal commentedon Jun 25, 2024
Closing, but this is kind of sad