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 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 |
OlderNewer