Created
March 14, 2019 17:44
-
-
Save porfirion/d3a2e9eb02440f3f3efd9a49b0245073 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
var str: "value" = "test" // error | |
var str2: "value" = "test" as "value" // ok | |
var str3: string = "my string" // assignment of healthy man | |
var str4: string = {} // error | |
var str5: string = {} as string // OK | |
var str6: string = {} as "anything" // OK!! | |
type Duumvirate = 1 | 2 | |
var int: Duumvirate = 3 as 1 // OK!!! | |
// idea of unions | |
type Tristate = "TRUE"|"FALSE"|"NONE"; | |
function foo(param: Tristate) { | |
return "enhanced: " + param; | |
} | |
let validInput = "NONE"; | |
foo(validInput as Tristate); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment