diff --git a/tests/baselines/reference/stringLiteralTypesAndTuples01.errors.txt b/tests/baselines/reference/stringLiteralTypesAndTuples01.errors.txt deleted file mode 100644 index 6a8704ce554..00000000000 --- a/tests/baselines/reference/stringLiteralTypesAndTuples01.errors.txt +++ /dev/null @@ -1,25 +0,0 @@ -tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts(6,37): error TS2304: Cannot find name 'Dinosaur'. - - -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts (1 errors) ==== - - // Should all be strings. - let [hello, brave, newish, world] = ["Hello", "Brave", "New", "World"]; - - type RexOrRaptor = "t-rex" | "raptor" - let [im, a, dinosaur]: ["I'm", "a", Dinosaur] = ['I\'m', 'a', 't-rex']; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Dinosaur'. - - rawr(dinosaur); - - function rawr(dino: RexOrRaptor) { - if (dino === "t-rex") { - return "ROAAAAR!"; - } - if (dino === "raptor") { - return "yip yip!"; - } - - throw "Unexpected " + dino; - } \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesAndTuples01.js b/tests/baselines/reference/stringLiteralTypesAndTuples01.js index 66e57b1eea5..ae02d12429a 100644 --- a/tests/baselines/reference/stringLiteralTypesAndTuples01.js +++ b/tests/baselines/reference/stringLiteralTypesAndTuples01.js @@ -4,7 +4,7 @@ let [hello, brave, newish, world] = ["Hello", "Brave", "New", "World"]; type RexOrRaptor = "t-rex" | "raptor" -let [im, a, dinosaur]: ["I'm", "a", Dinosaur] = ['I\'m', 'a', 't-rex']; +let [im, a, dinosaur]: ["I'm", "a", RexOrRaptor] = ['I\'m', 'a', 't-rex']; rawr(dinosaur); @@ -38,5 +38,5 @@ function rawr(dino) { //// [stringLiteralTypesAndTuples01.d.ts] declare let hello: string, brave: string, newish: string, world: string; declare type RexOrRaptor = "t-rex" | "raptor"; -declare let im: "I'm", a: "a", dinosaur: any; +declare let im: "I'm", a: "a", dinosaur: "t-rex" | "raptor"; declare function rawr(dino: RexOrRaptor): string; diff --git a/tests/baselines/reference/stringLiteralTypesAndTuples01.symbols b/tests/baselines/reference/stringLiteralTypesAndTuples01.symbols new file mode 100644 index 00000000000..b7ca53517ca --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesAndTuples01.symbols @@ -0,0 +1,41 @@ +=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts === + +// Should all be strings. +let [hello, brave, newish, world] = ["Hello", "Brave", "New", "World"]; +>hello : Symbol(hello, Decl(stringLiteralTypesAndTuples01.ts, 2, 5)) +>brave : Symbol(brave, Decl(stringLiteralTypesAndTuples01.ts, 2, 11)) +>newish : Symbol(newish, Decl(stringLiteralTypesAndTuples01.ts, 2, 18)) +>world : Symbol(world, Decl(stringLiteralTypesAndTuples01.ts, 2, 26)) + +type RexOrRaptor = "t-rex" | "raptor" +>RexOrRaptor : Symbol(RexOrRaptor, Decl(stringLiteralTypesAndTuples01.ts, 2, 71)) + +let [im, a, dinosaur]: ["I'm", "a", RexOrRaptor] = ['I\'m', 'a', 't-rex']; +>im : Symbol(im, Decl(stringLiteralTypesAndTuples01.ts, 5, 5)) +>a : Symbol(a, Decl(stringLiteralTypesAndTuples01.ts, 5, 8)) +>dinosaur : Symbol(dinosaur, Decl(stringLiteralTypesAndTuples01.ts, 5, 11)) +>RexOrRaptor : Symbol(RexOrRaptor, Decl(stringLiteralTypesAndTuples01.ts, 2, 71)) + +rawr(dinosaur); +>rawr : Symbol(rawr, Decl(stringLiteralTypesAndTuples01.ts, 7, 15)) +>dinosaur : Symbol(dinosaur, Decl(stringLiteralTypesAndTuples01.ts, 5, 11)) + +function rawr(dino: RexOrRaptor) { +>rawr : Symbol(rawr, Decl(stringLiteralTypesAndTuples01.ts, 7, 15)) +>dino : Symbol(dino, Decl(stringLiteralTypesAndTuples01.ts, 9, 14)) +>RexOrRaptor : Symbol(RexOrRaptor, Decl(stringLiteralTypesAndTuples01.ts, 2, 71)) + + if (dino === "t-rex") { +>dino : Symbol(dino, Decl(stringLiteralTypesAndTuples01.ts, 9, 14)) + + return "ROAAAAR!"; + } + if (dino === "raptor") { +>dino : Symbol(dino, Decl(stringLiteralTypesAndTuples01.ts, 9, 14)) + + return "yip yip!"; + } + + throw "Unexpected " + dino; +>dino : Symbol(dino, Decl(stringLiteralTypesAndTuples01.ts, 9, 14)) +} diff --git a/tests/baselines/reference/stringLiteralTypesAndTuples01.types b/tests/baselines/reference/stringLiteralTypesAndTuples01.types new file mode 100644 index 00000000000..740cf237412 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesAndTuples01.types @@ -0,0 +1,59 @@ +=== 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" : string +>"Brave" : string +>"New" : string +>"World" : string + +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 : "t-rex" | "raptor" +>RexOrRaptor : "t-rex" | "raptor" +>['I\'m', 'a', 't-rex'] : ["I'm", "a", "t-rex" | "raptor"] +>'I\'m' : "I'm" +>'a' : "a" +>'t-rex' : "t-rex" | "raptor" + +rawr(dinosaur); +>rawr(dinosaur) : string +>rawr : (dino: "t-rex" | "raptor") => string +>dinosaur : "t-rex" | "raptor" + +function rawr(dino: RexOrRaptor) { +>rawr : (dino: "t-rex" | "raptor") => string +>dino : "t-rex" | "raptor" +>RexOrRaptor : "t-rex" | "raptor" + + if (dino === "t-rex") { +>dino === "t-rex" : boolean +>dino : "t-rex" | "raptor" +>"t-rex" : string + + return "ROAAAAR!"; +>"ROAAAAR!" : string + } + if (dino === "raptor") { +>dino === "raptor" : boolean +>dino : "t-rex" | "raptor" +>"raptor" : string + + return "yip yip!"; +>"yip yip!" : string + } + + throw "Unexpected " + dino; +>"Unexpected " + dino : string +>"Unexpected " : string +>dino : "t-rex" | "raptor" +}