Skip to content

Instantly share code, notes, and snippets.

@vmasek
Created March 14, 2021 01:33
Show Gist options
  • Save vmasek/cfb444ce15b142a3371055a3c02929ff to your computer and use it in GitHub Desktop.
Save vmasek/cfb444ce15b142a3371055a3c02929ff to your computer and use it in GitHub Desktop.
Filter null & undefined predicate
const wololo: (string | number)[] =
['x', 42, null, undefined, 'foo']
.filter(<T>(item: T | null | undefined): item is T => !!item);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment