Skip to content

Instantly share code, notes, and snippets.

@LironHazan
Created May 22, 2021 05:39
Show Gist options
  • Save LironHazan/7ffd1926bc44e49e349ce42bf4b940f6 to your computer and use it in GitHub Desktop.
Save LironHazan/7ffd1926bc44e49e349ce42bf4b940f6 to your computer and use it in GitHub Desktop.
for my blog post
/**
* 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