mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-22 12:03:44 -05:00
Accepted baselines.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
42
tests/baselines/reference/stringLiteralTypesAndTuples01.js
Normal file
42
tests/baselines/reference/stringLiteralTypesAndTuples01.js
Normal 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;
|
||||
Reference in New Issue
Block a user