Created
June 15, 2021 22:40
-
-
Save eralston/b4e538fc5b2b6af21a0b0c618854a0ab to your computer and use it in GitHub Desktop.
Useful type guards in Typescript, for validating all your inputs
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
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