Last active
January 17, 2020 17:17
-
-
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
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
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