Created
May 22, 2021 05:39
-
-
Save LironHazan/7ffd1926bc44e49e349ce42bf4b940f6 to your computer and use it in GitHub Desktop.
for my blog post
This file contains hidden or 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
/** | |
* Since we don't have a type based pattern matching we're using "tags" runtime check | |
* @param result | |
*/ | |
export function isError<T, E extends ErrorClassification>(result: Result<E, T>): result is E { | |
return typeof result === 'object' && 'message' in result && 'type' in result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment