Created
December 17, 2019 18:23
-
-
Save carlrip/970d02d39c126ffc6d922eb303c5e902 to your computer and use it in GitHub Desktop.
const assertions - literals
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
function logStatus(status: "LOADING" | "LOADED") { | |
console.log(status); | |
} | |
const Status = { | |
Loading: "LOADING", | |
Loaded: "LOADED", | |
}; | |
logStatus(Status.Loading); // 💥 - Type error - Argument of type 'string' is not assignable to parameter of type '"LOADING" | "LOADED"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment