Skip to content

Instantly share code, notes, and snippets.

@eralston
Created June 15, 2021 22:40
Show Gist options
  • Save eralston/b4e538fc5b2b6af21a0b0c618854a0ab to your computer and use it in GitHub Desktop.
Save eralston/b4e538fc5b2b6af21a0b0c618854a0ab to your computer and use it in GitHub Desktop.
Useful type guards in Typescript, for validating all your inputs
function isValidNumber (it: unknown): it is number {
return it != null && typeof it === 'number' && !Number.isNaN(it)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment