Skip to content

Instantly share code, notes, and snippets.

@janjakubnanista
Last active May 22, 2020 14:24
Show Gist options
  • Save janjakubnanista/ba90c8b472a203f3bc3b030ff0d662d2 to your computer and use it in GitHub Desktop.
Save janjakubnanista/ba90c8b472a203f3bc3b030ff0d662d2 to your computer and use it in GitHub Desktop.
Checking for strings and numbers in TypeScript
// You can easily extend this example to check for
// number, boolean, bigint, Function and symbol types
const isString = (value: unknown): value is string => typeof value === 'string';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment