Skip to content

Instantly share code, notes, and snippets.

@michaeljscript
Last active April 2, 2019 19:46
Show Gist options
  • Save michaeljscript/90a96ba23b01960cbe6c8c3a4c10af50 to your computer and use it in GitHub Desktop.
Save michaeljscript/90a96ba23b01960cbe6c8c3a4c10af50 to your computer and use it in GitHub Desktop.
const createTypeGuard = <T>(parse: (val: unknown) => T | null) => (value: unknown): value is T => {
return parse(value) !== null;
}
const isPerson = createTypeGuard(parsePerson);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment