Last active
November 14, 2018 19:58
-
-
Save adamgen/95055b1957f9e851c2938c307f1d9e47 to your computer and use it in GitHub Desktop.
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
type a = 'aaa'; | |
const b = 'a' + 'a' + 'a'; | |
let c: a; | |
const IsA = (string: string): string is a => string === 'aaa'; | |
c = b; // gives an error | |
if (IsA(b)) { | |
c = b; // is ok because of the type guard | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment