Accepted baselines.

This commit is contained in:
Daniel Rosenwasser
2015-10-01 16:58:17 -07:00
parent 82545ce854
commit ed927d8cf6
2 changed files with 74 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts(6,5): error TS2322: Type '[string, string, string]' is not assignable to type '["I'm", "a", any]'.
Types of property '0' are incompatible.
Type 'string' is not assignable to type '"I'm"'.
tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts(6,37): error TS2304: Cannot find name 'Dinosaur'.
==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndTuples01.ts (2 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 TS2322: Type '[string, string, string]' is not assignable to type '["I'm", "a", any]'.
!!! error TS2322: Types of property '0' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type '"I'm"'.
~~~~~~~~
!!! 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;
}

View File

@@ -0,0 +1,42 @@
//// [stringLiteralTypesAndTuples01.ts]
// 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'];
rawr(dinosaur);
function rawr(dino: RexOrRaptor) {
if (dino === "t-rex") {
return "ROAAAAR!";
}
if (dino === "raptor") {
return "yip yip!";
}
throw "Unexpected " + dino;
}
//// [stringLiteralTypesAndTuples01.js]
// Should all be strings.
var _a = ["Hello", "Brave", "New", "World"], hello = _a[0], brave = _a[1], newish = _a[2], world = _a[3];
var _b = ['I\'m', 'a', 't-rex'], im = _b[0], a = _b[1], dinosaur = _b[2];
rawr(dinosaur);
function rawr(dino) {
if (dino === "t-rex") {
return "ROAAAAR!";
}
if (dino === "raptor") {
return "yip yip!";
}
throw "Unexpected " + 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 function rawr(dino: RexOrRaptor): string;