4 ms·
[1,2,undefined,3] .filter(<T>(x: T|undefined): x is T => typeof x !== 'undefined' ); Yes builtin lang support would be better, but that gets yo
by akdor1154 4y ago
[1,2,undefined,3]
.filter(<T>(x: T|undefined): x is T =>
typeof x !== 'undefined'
);
Yes builtin lang support would be better, but that gets you out of trouble in a pinch, without adding more 5 line npm baggage.
N.B. if you are in a JSX file, you'll need to add a comma: `<T,>`