Skip to content

Instantly share code, notes, and snippets.

@meekg33k
Last active January 17, 2020 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meekg33k/027a04b6e4ddcca64910940fdb7e0eaa to your computer and use it in GitHub Desktop.
Save meekg33k/027a04b6e4ddcca64910940fdb7e0eaa to your computer and use it in GitHub Desktop.
Logic to check if an animal type using type assertion https://medium.com/p/177b4a654ef6
const isCat = (animal: Animal):boolean => {
return (animal as Cat).meow
}
const isDog = (animal: Animal): boolean => {
return (animal as Dog).bark
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment