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
Overload Array.filter() to exclude nully when using Boolean #31551
I want to use Array.filter(Boolean) to filter out falsy values, e.g. nulls and empty strings from a string|null array. The result should be a string array. I am using strict mode (strictNullChecks).
The Array interface could be extended with something like this:
Duplicate of #16655 I believe. Which was included and then reverted due to it causing breaking changes. Comment
This was reverted due to it causing a breaking change in 3.5. The simple repro looks like this:
declareconstBullean: {new(value?: any): Boolean;<T>(value?: T): value is Exclude<T,false|null|undefined|''|0>;};declareconstarr: any[];// Was any[], now (3.5) unknown[]constarr2=arr.filter(Bullean);
There might be something wrong in generic inference, but it's not yet clear. We'll need this scenario to work before adding it back in.
Activity
dragomirtitian commentedon May 23, 2019
Duplicate of #16655 I believe. Which was included and then reverted due to it causing breaking changes. Comment
typescript-bot commentedon May 25, 2019
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.