Accepted baselines.

This commit is contained in:
Daniel Rosenwasser 2015-11-10 11:56:50 -08:00
parent 3812745737
commit f80a6c6e86
8 changed files with 179 additions and 0 deletions

View File

@ -0,0 +1,26 @@
//// [stringLiteralTypesAndLogicalOrExpressions01.ts]
declare function myRandBool(): boolean;
let a: "foo" = "foo";
let b = a || "foo";
let c: "foo" = b;
let d = b || "bar";
let e: "foo" | "bar" = d;
//// [stringLiteralTypesAndLogicalOrExpressions01.js]
var a = "foo";
var b = a || "foo";
var c = b;
var d = b || "bar";
var e = d;
//// [stringLiteralTypesAndLogicalOrExpressions01.d.ts]
declare function myRandBool(): boolean;
declare let a: "foo";
declare let b: "foo";
declare let c: "foo";
declare let d: "foo" | "bar";
declare let e: "foo" | "bar";

View File

@ -0,0 +1,24 @@
=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndLogicalOrExpressions01.ts ===
declare function myRandBool(): boolean;
>myRandBool : Symbol(myRandBool, Decl(stringLiteralTypesAndLogicalOrExpressions01.ts, 0, 0))
let a: "foo" = "foo";
>a : Symbol(a, Decl(stringLiteralTypesAndLogicalOrExpressions01.ts, 3, 3))
let b = a || "foo";
>b : Symbol(b, Decl(stringLiteralTypesAndLogicalOrExpressions01.ts, 4, 3))
>a : Symbol(a, Decl(stringLiteralTypesAndLogicalOrExpressions01.ts, 3, 3))
let c: "foo" = b;
>c : Symbol(c, Decl(stringLiteralTypesAndLogicalOrExpressions01.ts, 5, 3))
>b : Symbol(b, Decl(stringLiteralTypesAndLogicalOrExpressions01.ts, 4, 3))
let d = b || "bar";
>d : Symbol(d, Decl(stringLiteralTypesAndLogicalOrExpressions01.ts, 6, 3))
>b : Symbol(b, Decl(stringLiteralTypesAndLogicalOrExpressions01.ts, 4, 3))
let e: "foo" | "bar" = d;
>e : Symbol(e, Decl(stringLiteralTypesAndLogicalOrExpressions01.ts, 7, 3))
>d : Symbol(d, Decl(stringLiteralTypesAndLogicalOrExpressions01.ts, 6, 3))

View File

@ -0,0 +1,29 @@
=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndLogicalOrExpressions01.ts ===
declare function myRandBool(): boolean;
>myRandBool : () => boolean
let a: "foo" = "foo";
>a : "foo"
>"foo" : "foo"
let b = a || "foo";
>b : "foo"
>a || "foo" : "foo"
>a : "foo"
>"foo" : "foo"
let c: "foo" = b;
>c : "foo"
>b : "foo"
let d = b || "bar";
>d : "foo" | "bar"
>b || "bar" : "foo" | "bar"
>b : "foo"
>"bar" : "bar"
let e: "foo" | "bar" = d;
>e : "foo" | "bar"
>d : "foo" | "bar"

View File

@ -0,0 +1,17 @@
tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndParenthesizedExpressions01.ts(4,5): error TS2322: Type 'string' is not assignable to type '"foo"'.
tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndParenthesizedExpressions01.ts(6,5): error TS2322: Type 'string' is not assignable to type '"foo"'.
==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndParenthesizedExpressions01.ts (2 errors) ====
declare function myRandBool(): boolean;
let a: "foo" = ("foo");
~
!!! error TS2322: Type 'string' is not assignable to type '"foo"'.
let b: "foo" | "bar" = ("foo");
let c: "foo" = (myRandBool ? "foo" : ("foo"));
~
!!! error TS2322: Type 'string' is not assignable to type '"foo"'.
let d: "foo" | "bar" = (myRandBool ? "foo" : ("bar"));

View File

@ -0,0 +1,23 @@
//// [stringLiteralTypesAndParenthesizedExpressions01.ts]
declare function myRandBool(): boolean;
let a: "foo" = ("foo");
let b: "foo" | "bar" = ("foo");
let c: "foo" = (myRandBool ? "foo" : ("foo"));
let d: "foo" | "bar" = (myRandBool ? "foo" : ("bar"));
//// [stringLiteralTypesAndParenthesizedExpressions01.js]
var a = ("foo");
var b = ("foo");
var c = (myRandBool ? "foo" : ("foo"));
var d = (myRandBool ? "foo" : ("bar"));
//// [stringLiteralTypesAndParenthesizedExpressions01.d.ts]
declare function myRandBool(): boolean;
declare let a: "foo";
declare let b: "foo" | "bar";
declare let c: "foo";
declare let d: "foo" | "bar";

View File

@ -0,0 +1,18 @@
//// [stringLiteralTypesOverloads04.ts]
declare function f(x: (p: "foo" | "bar") => "foo");
f(y => {
let z = y = "foo";
return z;
})
//// [stringLiteralTypesOverloads04.js]
f(function (y) {
var z = y = "foo";
return z;
});
//// [stringLiteralTypesOverloads04.d.ts]
declare function f(x: (p: "foo" | "bar") => "foo"): any;

View File

@ -0,0 +1,19 @@
=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads04.ts ===
declare function f(x: (p: "foo" | "bar") => "foo");
>f : Symbol(f, Decl(stringLiteralTypesOverloads04.ts, 0, 0))
>x : Symbol(x, Decl(stringLiteralTypesOverloads04.ts, 1, 19))
>p : Symbol(p, Decl(stringLiteralTypesOverloads04.ts, 1, 23))
f(y => {
>f : Symbol(f, Decl(stringLiteralTypesOverloads04.ts, 0, 0))
>y : Symbol(y, Decl(stringLiteralTypesOverloads04.ts, 3, 2))
let z = y = "foo";
>z : Symbol(z, Decl(stringLiteralTypesOverloads04.ts, 4, 7))
>y : Symbol(y, Decl(stringLiteralTypesOverloads04.ts, 3, 2))
return z;
>z : Symbol(z, Decl(stringLiteralTypesOverloads04.ts, 4, 7))
})

View File

@ -0,0 +1,23 @@
=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads04.ts ===
declare function f(x: (p: "foo" | "bar") => "foo");
>f : (x: (p: "foo" | "bar") => "foo") => any
>x : (p: "foo" | "bar") => "foo"
>p : "foo" | "bar"
f(y => {
>f(y => { let z = y = "foo"; return z;}) : any
>f : (x: (p: "foo" | "bar") => "foo") => any
>y => { let z = y = "foo"; return z;} : (y: "foo" | "bar") => "foo"
>y : "foo" | "bar"
let z = y = "foo";
>z : "foo"
>y = "foo" : "foo"
>y : "foo" | "bar"
>"foo" : "foo"
return z;
>z : "foo"
})