Create Type Guard
Simple package for creating type-safe type guards for TypeScript.
What problem is being solved?
// Oooops, you forgot to check if the `age` property does exist in `data`.// Oooops, you forgot to check the type of the `name` property. Is it a string? Is it a number?// Oooops, you forgot to check the type of the `age` property. Is it a string? Is it a number? // With create-typeguard this won't happen.
How does it work?
This package creates type-safe type guards from a parsers, because parsers will warn us if we make a mistake!
Usage
; // Our parser function that is type-safe // This is now a type-safe typeguard for Person!; ; if isPersonmaybePerson
Usage 2 - Without defining a separate parse function
; // You do not have to create a separate parse function.; ; if isPersonmaybePerson
Why create-typeguard?
Read more at this blog post https://medium.com/@michalszorad/typescript-keeping-type-guards-safe-and-up-to-date-2457d52bd722