Created
March 24, 2021 23:17
-
-
Save maslade/115f34af786674067899a568aa7cf4dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const list: Array<number | string> = [1, 'two', 3, 'four']; | |
// the implicit type of both of these consts is Array<string | number> -- not helpful! | |
const numbers = list.filter(thing => typeof thing === 'number'); | |
const strings = list.filter(thing => typeof thing === 'string'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment