Created
June 10, 2022 17:41
-
-
Save Elijah-trillionz/fa8db0973e1857ccaf50c203067d416e to your computer and use it in GitHub Desktop.
type annotations with "as" keyword
This file contains 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 animal: 'dog' | 'tiger' | 'lion' = 'dog'; | |
const printDomesticAnimal = (animal: 'dog' | 'cat') => { | |
return animal; | |
} | |
printDomesticAnimal('tiger'); // bringing the tiger as tiger will be a problem | |
printDomesticAnimal('tiger' as 'dog'); // bringing the tiger as a dog |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment