1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts ===
// Should all be strings.
let [hello, brave, newish, world] = ["Hello", "Brave", "New", "World"];
>hello : string
>brave : string
>newish : string
>world : string
>["Hello", "Brave", "New", "World"] : [string, string, string, string]
>"Hello" : "Hello"
>"Brave" : "Brave"
>"New" : "New"
>"World" : "World"
type RexOrRaptor = "t-rex" | "raptor"
>RexOrRaptor : "t-rex" | "raptor"
let [im, a, dinosaur]: ["I'm", "a", RexOrRaptor] = ['I\'m', 'a', 't-rex'];
>im : "I'm"
>a : "a"
>dinosaur : RexOrRaptor
>['I\'m', 'a', 't-rex'] : ["I'm", "a", "t-rex"]
>'I\'m' : "I'm"
>'a' : "a"
>'t-rex' : "t-rex"
rawr(dinosaur);
>rawr(dinosaur) : "ROAAAAR!" | "yip yip!"
>rawr : (dino: RexOrRaptor) => "ROAAAAR!" | "yip yip!"
>dinosaur : "t-rex"
function rawr(dino: RexOrRaptor) {
>rawr : (dino: RexOrRaptor) => "ROAAAAR!" | "yip yip!"
>dino : RexOrRaptor
if (dino === "t-rex") {
>dino === "t-rex" : boolean
>dino : RexOrRaptor
>"t-rex" : "t-rex"
return "ROAAAAR!";
>"ROAAAAR!" : "ROAAAAR!"
}
if (dino === "raptor") {
>dino === "raptor" : boolean
>dino : "raptor"
>"raptor" : "raptor"
return "yip yip!";
>"yip yip!" : "yip yip!"
}
throw "Unexpected " + dino;
>"Unexpected " + dino : string
>"Unexpected " : "Unexpected "
>dino : never
}
|