Accepted baselines.

This commit is contained in:
Daniel Rosenwasser 2015-11-06 12:59:06 -08:00
parent 8dbfe1ca63
commit a1fcfaf574
16 changed files with 546 additions and 174 deletions

View File

@ -1,26 +0,0 @@
tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf01.ts(6,9): error TS2365: Operator '===' cannot be applied to types '("a" | "b")[] | "a" | "b"' and 'string'.
tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf01.ts(9,14): error TS2365: Operator '===' cannot be applied to types '("a" | "b")[] | "a" | "b"' and 'string'.
==== tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf01.ts (2 errors) ====
type S = "a" | "b";
type T = S[] | S;
function f(foo: T) {
if (foo === "a") {
~~~~~~~~~~~
!!! error TS2365: Operator '===' cannot be applied to types '("a" | "b")[] | "a" | "b"' and 'string'.
return foo;
}
else if (foo === "b") {
~~~~~~~~~~~
!!! error TS2365: Operator '===' cannot be applied to types '("a" | "b")[] | "a" | "b"' and 'string'.
return foo;
}
else {
return (foo as S[])[0];
}
throw new Error("Unreachable code hit.");
}

View File

@ -0,0 +1,36 @@
=== tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf01.ts ===
type S = "a" | "b";
>S : Symbol(S, Decl(stringLiteralCheckedInIf01.ts, 0, 0))
type T = S[] | S;
>T : Symbol(T, Decl(stringLiteralCheckedInIf01.ts, 1, 19))
>S : Symbol(S, Decl(stringLiteralCheckedInIf01.ts, 0, 0))
>S : Symbol(S, Decl(stringLiteralCheckedInIf01.ts, 0, 0))
function f(foo: T) {
>f : Symbol(f, Decl(stringLiteralCheckedInIf01.ts, 2, 17))
>foo : Symbol(foo, Decl(stringLiteralCheckedInIf01.ts, 4, 11))
>T : Symbol(T, Decl(stringLiteralCheckedInIf01.ts, 1, 19))
if (foo === "a") {
>foo : Symbol(foo, Decl(stringLiteralCheckedInIf01.ts, 4, 11))
return foo;
>foo : Symbol(foo, Decl(stringLiteralCheckedInIf01.ts, 4, 11))
}
else if (foo === "b") {
>foo : Symbol(foo, Decl(stringLiteralCheckedInIf01.ts, 4, 11))
return foo;
>foo : Symbol(foo, Decl(stringLiteralCheckedInIf01.ts, 4, 11))
}
else {
return (foo as S[])[0];
>foo : Symbol(foo, Decl(stringLiteralCheckedInIf01.ts, 4, 11))
>S : Symbol(S, Decl(stringLiteralCheckedInIf01.ts, 0, 0))
}
throw new Error("Unreachable code hit.");
>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
}

View File

@ -0,0 +1,46 @@
=== tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf01.ts ===
type S = "a" | "b";
>S : "a" | "b"
type T = S[] | S;
>T : ("a" | "b")[] | "a" | "b"
>S : "a" | "b"
>S : "a" | "b"
function f(foo: T) {
>f : (foo: ("a" | "b")[] | "a" | "b") => ("a" | "b")[] | "a" | "b"
>foo : ("a" | "b")[] | "a" | "b"
>T : ("a" | "b")[] | "a" | "b"
if (foo === "a") {
>foo === "a" : boolean
>foo : ("a" | "b")[] | "a" | "b"
>"a" : string
return foo;
>foo : ("a" | "b")[] | "a" | "b"
}
else if (foo === "b") {
>foo === "b" : boolean
>foo : ("a" | "b")[] | "a" | "b"
>"b" : string
return foo;
>foo : ("a" | "b")[] | "a" | "b"
}
else {
return (foo as S[])[0];
>(foo as S[])[0] : "a" | "b"
>(foo as S[]) : ("a" | "b")[]
>foo as S[] : ("a" | "b")[]
>foo : ("a" | "b")[] | "a" | "b"
>S : "a" | "b"
>0 : number
}
throw new Error("Unreachable code hit.");
>new Error("Unreachable code hit.") : Error
>Error : ErrorConstructor
>"Unreachable code hit." : string
}

View File

@ -1,27 +0,0 @@
tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf02.ts(6,12): error TS2365: Operator '===' cannot be applied to types '("a" | "b")[] | "a" | "b"' and 'string'.
tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf02.ts(6,25): error TS2365: Operator '===' cannot be applied to types '("a" | "b")[] | "a" | "b"' and 'string'.
==== tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf02.ts (2 errors) ====
type S = "a" | "b";
type T = S[] | S;
function isS(t: T): t is S {
return t === "a" || t === "b";
~~~~~~~~~
!!! error TS2365: Operator '===' cannot be applied to types '("a" | "b")[] | "a" | "b"' and 'string'.
~~~~~~~~~
!!! error TS2365: Operator '===' cannot be applied to types '("a" | "b")[] | "a" | "b"' and 'string'.
}
function f(foo: T) {
if (isS(foo)) {
return foo;
}
else {
return foo[0];
}
throw new Error("Unreachable code hit.");
}

View File

@ -0,0 +1,42 @@
=== tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf02.ts ===
type S = "a" | "b";
>S : Symbol(S, Decl(stringLiteralCheckedInIf02.ts, 0, 0))
type T = S[] | S;
>T : Symbol(T, Decl(stringLiteralCheckedInIf02.ts, 1, 19))
>S : Symbol(S, Decl(stringLiteralCheckedInIf02.ts, 0, 0))
>S : Symbol(S, Decl(stringLiteralCheckedInIf02.ts, 0, 0))
function isS(t: T): t is S {
>isS : Symbol(isS, Decl(stringLiteralCheckedInIf02.ts, 2, 17))
>t : Symbol(t, Decl(stringLiteralCheckedInIf02.ts, 4, 13))
>T : Symbol(T, Decl(stringLiteralCheckedInIf02.ts, 1, 19))
>t : Symbol(t, Decl(stringLiteralCheckedInIf02.ts, 4, 13))
>S : Symbol(S, Decl(stringLiteralCheckedInIf02.ts, 0, 0))
return t === "a" || t === "b";
>t : Symbol(t, Decl(stringLiteralCheckedInIf02.ts, 4, 13))
>t : Symbol(t, Decl(stringLiteralCheckedInIf02.ts, 4, 13))
}
function f(foo: T) {
>f : Symbol(f, Decl(stringLiteralCheckedInIf02.ts, 6, 1))
>foo : Symbol(foo, Decl(stringLiteralCheckedInIf02.ts, 8, 11))
>T : Symbol(T, Decl(stringLiteralCheckedInIf02.ts, 1, 19))
if (isS(foo)) {
>isS : Symbol(isS, Decl(stringLiteralCheckedInIf02.ts, 2, 17))
>foo : Symbol(foo, Decl(stringLiteralCheckedInIf02.ts, 8, 11))
return foo;
>foo : Symbol(foo, Decl(stringLiteralCheckedInIf02.ts, 8, 11))
}
else {
return foo[0];
>foo : Symbol(foo, Decl(stringLiteralCheckedInIf02.ts, 8, 11))
}
throw new Error("Unreachable code hit.");
>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
}

View File

@ -0,0 +1,52 @@
=== tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf02.ts ===
type S = "a" | "b";
>S : "a" | "b"
type T = S[] | S;
>T : ("a" | "b")[] | "a" | "b"
>S : "a" | "b"
>S : "a" | "b"
function isS(t: T): t is S {
>isS : (t: ("a" | "b")[] | "a" | "b") => t is "a" | "b"
>t : ("a" | "b")[] | "a" | "b"
>T : ("a" | "b")[] | "a" | "b"
>t : any
>S : "a" | "b"
return t === "a" || t === "b";
>t === "a" || t === "b" : boolean
>t === "a" : boolean
>t : ("a" | "b")[] | "a" | "b"
>"a" : string
>t === "b" : boolean
>t : ("a" | "b")[] | "a" | "b"
>"b" : string
}
function f(foo: T) {
>f : (foo: ("a" | "b")[] | "a" | "b") => "a" | "b"
>foo : ("a" | "b")[] | "a" | "b"
>T : ("a" | "b")[] | "a" | "b"
if (isS(foo)) {
>isS(foo) : boolean
>isS : (t: ("a" | "b")[] | "a" | "b") => t is "a" | "b"
>foo : ("a" | "b")[] | "a" | "b"
return foo;
>foo : "a" | "b"
}
else {
return foo[0];
>foo[0] : "a" | "b"
>foo : ("a" | "b")[]
>0 : number
}
throw new Error("Unreachable code hit.");
>new Error("Unreachable code hit.") : Error
>Error : ErrorConstructor
>"Unreachable code hit." : string
}

View File

@ -1,26 +0,0 @@
tests/cases/conformance/types/stringLiteral/stringLiteralMatchedInSwitch01.ts(7,10): error TS2322: Type 'string' is not assignable to type '("a" | "b")[] | "a" | "b"'.
Type 'string' is not assignable to type '"b"'.
tests/cases/conformance/types/stringLiteral/stringLiteralMatchedInSwitch01.ts(8,10): error TS2322: Type 'string' is not assignable to type '("a" | "b")[] | "a" | "b"'.
Type 'string' is not assignable to type '"b"'.
==== tests/cases/conformance/types/stringLiteral/stringLiteralMatchedInSwitch01.ts (2 errors) ====
type S = "a" | "b";
type T = S[] | S;
var foo: T;
switch (foo) {
case "a":
~~~
!!! error TS2322: Type 'string' is not assignable to type '("a" | "b")[] | "a" | "b"'.
!!! error TS2322: Type 'string' is not assignable to type '"b"'.
case "b":
~~~
!!! error TS2322: Type 'string' is not assignable to type '("a" | "b")[] | "a" | "b"'.
!!! error TS2322: Type 'string' is not assignable to type '"b"'.
break;
default:
foo = (foo as S[])[0];
break;
}

View File

@ -0,0 +1,28 @@
=== tests/cases/conformance/types/stringLiteral/stringLiteralMatchedInSwitch01.ts ===
type S = "a" | "b";
>S : Symbol(S, Decl(stringLiteralMatchedInSwitch01.ts, 0, 0))
type T = S[] | S;
>T : Symbol(T, Decl(stringLiteralMatchedInSwitch01.ts, 1, 19))
>S : Symbol(S, Decl(stringLiteralMatchedInSwitch01.ts, 0, 0))
>S : Symbol(S, Decl(stringLiteralMatchedInSwitch01.ts, 0, 0))
var foo: T;
>foo : Symbol(foo, Decl(stringLiteralMatchedInSwitch01.ts, 4, 3))
>T : Symbol(T, Decl(stringLiteralMatchedInSwitch01.ts, 1, 19))
switch (foo) {
>foo : Symbol(foo, Decl(stringLiteralMatchedInSwitch01.ts, 4, 3))
case "a":
case "b":
break;
default:
foo = (foo as S[])[0];
>foo : Symbol(foo, Decl(stringLiteralMatchedInSwitch01.ts, 4, 3))
>foo : Symbol(foo, Decl(stringLiteralMatchedInSwitch01.ts, 4, 3))
>S : Symbol(S, Decl(stringLiteralMatchedInSwitch01.ts, 0, 0))
break;
}

View File

@ -0,0 +1,37 @@
=== tests/cases/conformance/types/stringLiteral/stringLiteralMatchedInSwitch01.ts ===
type S = "a" | "b";
>S : "a" | "b"
type T = S[] | S;
>T : ("a" | "b")[] | "a" | "b"
>S : "a" | "b"
>S : "a" | "b"
var foo: T;
>foo : ("a" | "b")[] | "a" | "b"
>T : ("a" | "b")[] | "a" | "b"
switch (foo) {
>foo : ("a" | "b")[] | "a" | "b"
case "a":
>"a" : string
case "b":
>"b" : string
break;
default:
foo = (foo as S[])[0];
>foo = (foo as S[])[0] : "a" | "b"
>foo : ("a" | "b")[] | "a" | "b"
>(foo as S[])[0] : "a" | "b"
>(foo as S[]) : ("a" | "b")[]
>foo as S[] : ("a" | "b")[]
>foo : ("a" | "b")[] | "a" | "b"
>S : "a" | "b"
>0 : number
break;
}

View File

@ -1,55 +0,0 @@
tests/cases/conformance/types/stringLiteral/stringLiteralTypeAssertion01.ts(22,5): error TS2352: Neither type 'string' nor type '("a" | "b")[] | "a" | "b"' is assignable to the other.
Type 'string' is not assignable to type '"b"'.
tests/cases/conformance/types/stringLiteral/stringLiteralTypeAssertion01.ts(23,5): error TS2352: Neither type 'string' nor type '("a" | "b")[] | "a" | "b"' is assignable to the other.
Type 'string' is not assignable to type '"b"'.
tests/cases/conformance/types/stringLiteral/stringLiteralTypeAssertion01.ts(30,7): error TS2352: Neither type '("a" | "b")[] | "a" | "b"' nor type 'string' is assignable to the other.
Type '("a" | "b")[]' is not assignable to type 'string'.
tests/cases/conformance/types/stringLiteral/stringLiteralTypeAssertion01.ts(31,7): error TS2352: Neither type '("a" | "b")[] | "a" | "b"' nor type 'string' is assignable to the other.
Type '("a" | "b")[]' is not assignable to type 'string'.
==== tests/cases/conformance/types/stringLiteral/stringLiteralTypeAssertion01.ts (4 errors) ====
type S = "a" | "b";
type T = S[] | S;
var s: S;
var t: T;
var str: string;
////////////////
s = <S>t;
s = t as S;
s = <S>str;
s = str as S;
////////////////
t = <T>s;
t = s as T;
t = <T>str;
~~~~~~
!!! error TS2352: Neither type 'string' nor type '("a" | "b")[] | "a" | "b"' is assignable to the other.
!!! error TS2352: Type 'string' is not assignable to type '"b"'.
t = str as T;
~~~~~~~~
!!! error TS2352: Neither type 'string' nor type '("a" | "b")[] | "a" | "b"' is assignable to the other.
!!! error TS2352: Type 'string' is not assignable to type '"b"'.
////////////////
str = <string>s;
str = s as string;
str = <string>t;
~~~~~~~~~
!!! error TS2352: Neither type '("a" | "b")[] | "a" | "b"' nor type 'string' is assignable to the other.
!!! error TS2352: Type '("a" | "b")[]' is not assignable to type 'string'.
str = t as string;
~~~~~~~~~~~
!!! error TS2352: Neither type '("a" | "b")[] | "a" | "b"' nor type 'string' is assignable to the other.
!!! error TS2352: Type '("a" | "b")[]' is not assignable to type 'string'.

View File

@ -0,0 +1,83 @@
=== tests/cases/conformance/types/stringLiteral/stringLiteralTypeAssertion01.ts ===
type S = "a" | "b";
>S : Symbol(S, Decl(stringLiteralTypeAssertion01.ts, 0, 0))
type T = S[] | S;
>T : Symbol(T, Decl(stringLiteralTypeAssertion01.ts, 1, 19))
>S : Symbol(S, Decl(stringLiteralTypeAssertion01.ts, 0, 0))
>S : Symbol(S, Decl(stringLiteralTypeAssertion01.ts, 0, 0))
var s: S;
>s : Symbol(s, Decl(stringLiteralTypeAssertion01.ts, 4, 3))
>S : Symbol(S, Decl(stringLiteralTypeAssertion01.ts, 0, 0))
var t: T;
>t : Symbol(t, Decl(stringLiteralTypeAssertion01.ts, 5, 3))
>T : Symbol(T, Decl(stringLiteralTypeAssertion01.ts, 1, 19))
var str: string;
>str : Symbol(str, Decl(stringLiteralTypeAssertion01.ts, 6, 3))
////////////////
s = <S>t;
>s : Symbol(s, Decl(stringLiteralTypeAssertion01.ts, 4, 3))
>S : Symbol(S, Decl(stringLiteralTypeAssertion01.ts, 0, 0))
>t : Symbol(t, Decl(stringLiteralTypeAssertion01.ts, 5, 3))
s = t as S;
>s : Symbol(s, Decl(stringLiteralTypeAssertion01.ts, 4, 3))
>t : Symbol(t, Decl(stringLiteralTypeAssertion01.ts, 5, 3))
>S : Symbol(S, Decl(stringLiteralTypeAssertion01.ts, 0, 0))
s = <S>str;
>s : Symbol(s, Decl(stringLiteralTypeAssertion01.ts, 4, 3))
>S : Symbol(S, Decl(stringLiteralTypeAssertion01.ts, 0, 0))
>str : Symbol(str, Decl(stringLiteralTypeAssertion01.ts, 6, 3))
s = str as S;
>s : Symbol(s, Decl(stringLiteralTypeAssertion01.ts, 4, 3))
>str : Symbol(str, Decl(stringLiteralTypeAssertion01.ts, 6, 3))
>S : Symbol(S, Decl(stringLiteralTypeAssertion01.ts, 0, 0))
////////////////
t = <T>s;
>t : Symbol(t, Decl(stringLiteralTypeAssertion01.ts, 5, 3))
>T : Symbol(T, Decl(stringLiteralTypeAssertion01.ts, 1, 19))
>s : Symbol(s, Decl(stringLiteralTypeAssertion01.ts, 4, 3))
t = s as T;
>t : Symbol(t, Decl(stringLiteralTypeAssertion01.ts, 5, 3))
>s : Symbol(s, Decl(stringLiteralTypeAssertion01.ts, 4, 3))
>T : Symbol(T, Decl(stringLiteralTypeAssertion01.ts, 1, 19))
t = <T>str;
>t : Symbol(t, Decl(stringLiteralTypeAssertion01.ts, 5, 3))
>T : Symbol(T, Decl(stringLiteralTypeAssertion01.ts, 1, 19))
>str : Symbol(str, Decl(stringLiteralTypeAssertion01.ts, 6, 3))
t = str as T;
>t : Symbol(t, Decl(stringLiteralTypeAssertion01.ts, 5, 3))
>str : Symbol(str, Decl(stringLiteralTypeAssertion01.ts, 6, 3))
>T : Symbol(T, Decl(stringLiteralTypeAssertion01.ts, 1, 19))
////////////////
str = <string>s;
>str : Symbol(str, Decl(stringLiteralTypeAssertion01.ts, 6, 3))
>s : Symbol(s, Decl(stringLiteralTypeAssertion01.ts, 4, 3))
str = s as string;
>str : Symbol(str, Decl(stringLiteralTypeAssertion01.ts, 6, 3))
>s : Symbol(s, Decl(stringLiteralTypeAssertion01.ts, 4, 3))
str = <string>t;
>str : Symbol(str, Decl(stringLiteralTypeAssertion01.ts, 6, 3))
>t : Symbol(t, Decl(stringLiteralTypeAssertion01.ts, 5, 3))
str = t as string;
>str : Symbol(str, Decl(stringLiteralTypeAssertion01.ts, 6, 3))
>t : Symbol(t, Decl(stringLiteralTypeAssertion01.ts, 5, 3))

View File

@ -0,0 +1,107 @@
=== tests/cases/conformance/types/stringLiteral/stringLiteralTypeAssertion01.ts ===
type S = "a" | "b";
>S : "a" | "b"
type T = S[] | S;
>T : ("a" | "b")[] | "a" | "b"
>S : "a" | "b"
>S : "a" | "b"
var s: S;
>s : "a" | "b"
>S : "a" | "b"
var t: T;
>t : ("a" | "b")[] | "a" | "b"
>T : ("a" | "b")[] | "a" | "b"
var str: string;
>str : string
////////////////
s = <S>t;
>s = <S>t : "a" | "b"
>s : "a" | "b"
><S>t : "a" | "b"
>S : "a" | "b"
>t : ("a" | "b")[] | "a" | "b"
s = t as S;
>s = t as S : "a" | "b"
>s : "a" | "b"
>t as S : "a" | "b"
>t : ("a" | "b")[] | "a" | "b"
>S : "a" | "b"
s = <S>str;
>s = <S>str : "a" | "b"
>s : "a" | "b"
><S>str : "a" | "b"
>S : "a" | "b"
>str : string
s = str as S;
>s = str as S : "a" | "b"
>s : "a" | "b"
>str as S : "a" | "b"
>str : string
>S : "a" | "b"
////////////////
t = <T>s;
>t = <T>s : ("a" | "b")[] | "a" | "b"
>t : ("a" | "b")[] | "a" | "b"
><T>s : ("a" | "b")[] | "a" | "b"
>T : ("a" | "b")[] | "a" | "b"
>s : "a" | "b"
t = s as T;
>t = s as T : ("a" | "b")[] | "a" | "b"
>t : ("a" | "b")[] | "a" | "b"
>s as T : ("a" | "b")[] | "a" | "b"
>s : "a" | "b"
>T : ("a" | "b")[] | "a" | "b"
t = <T>str;
>t = <T>str : ("a" | "b")[] | "a" | "b"
>t : ("a" | "b")[] | "a" | "b"
><T>str : ("a" | "b")[] | "a" | "b"
>T : ("a" | "b")[] | "a" | "b"
>str : string
t = str as T;
>t = str as T : ("a" | "b")[] | "a" | "b"
>t : ("a" | "b")[] | "a" | "b"
>str as T : ("a" | "b")[] | "a" | "b"
>str : string
>T : ("a" | "b")[] | "a" | "b"
////////////////
str = <string>s;
>str = <string>s : string
>str : string
><string>s : string
>s : "a" | "b"
str = s as string;
>str = s as string : string
>str : string
>s as string : string
>s : "a" | "b"
str = <string>t;
>str = <string>t : string
>str : string
><string>t : string
>t : ("a" | "b")[] | "a" | "b"
str = t as string;
>str = t as string : string
>str : string
>t as string : string
>t : ("a" | "b")[] | "a" | "b"

View File

@ -1,29 +0,0 @@
tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(7,5): error TS2365: Operator '===' cannot be applied to types '"foo" | "bar" | number' and 'string'.
tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(10,10): error TS2365: Operator '!==' cannot be applied to types '"foo" | "bar" | number' and 'string'.
==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts (2 errors) ====
type T = number | "foo" | "bar";
var x: "foo" | "bar" | number;
var y: T = "bar";
if (x === "foo") {
~~~~~~~~~~~
!!! error TS2365: Operator '===' cannot be applied to types '"foo" | "bar" | number' and 'string'.
let a = x;
}
else if (x !== "bar") {
~~~~~~~~~~~
!!! error TS2365: Operator '!==' cannot be applied to types '"foo" | "bar" | number' and 'string'.
let b = x || y;
}
else {
let c = x;
let d = y;
let e: (typeof x) | (typeof y) = c || d;
}
x = y;
y = x;

View File

@ -0,0 +1,52 @@
=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts ===
type T = number | "foo" | "bar";
>T : Symbol(T, Decl(stringLiteralTypesInUnionTypes03.ts, 0, 0))
var x: "foo" | "bar" | number;
>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes03.ts, 3, 3))
var y: T = "bar";
>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes03.ts, 4, 3))
>T : Symbol(T, Decl(stringLiteralTypesInUnionTypes03.ts, 0, 0))
if (x === "foo") {
>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes03.ts, 3, 3))
let a = x;
>a : Symbol(a, Decl(stringLiteralTypesInUnionTypes03.ts, 7, 7))
>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes03.ts, 3, 3))
}
else if (x !== "bar") {
>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes03.ts, 3, 3))
let b = x || y;
>b : Symbol(b, Decl(stringLiteralTypesInUnionTypes03.ts, 10, 7))
>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes03.ts, 3, 3))
>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes03.ts, 4, 3))
}
else {
let c = x;
>c : Symbol(c, Decl(stringLiteralTypesInUnionTypes03.ts, 13, 7))
>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes03.ts, 3, 3))
let d = y;
>d : Symbol(d, Decl(stringLiteralTypesInUnionTypes03.ts, 14, 7))
>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes03.ts, 4, 3))
let e: (typeof x) | (typeof y) = c || d;
>e : Symbol(e, Decl(stringLiteralTypesInUnionTypes03.ts, 15, 7))
>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes03.ts, 3, 3))
>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes03.ts, 4, 3))
>c : Symbol(c, Decl(stringLiteralTypesInUnionTypes03.ts, 13, 7))
>d : Symbol(d, Decl(stringLiteralTypesInUnionTypes03.ts, 14, 7))
}
x = y;
>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes03.ts, 3, 3))
>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes03.ts, 4, 3))
y = x;
>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes03.ts, 4, 3))
>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes03.ts, 3, 3))

View File

@ -0,0 +1,61 @@
=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts ===
type T = number | "foo" | "bar";
>T : number | "foo" | "bar"
var x: "foo" | "bar" | number;
>x : "foo" | "bar" | number
var y: T = "bar";
>y : number | "foo" | "bar"
>T : number | "foo" | "bar"
>"bar" : "bar"
if (x === "foo") {
>x === "foo" : boolean
>x : "foo" | "bar" | number
>"foo" : string
let a = x;
>a : "foo" | "bar" | number
>x : "foo" | "bar" | number
}
else if (x !== "bar") {
>x !== "bar" : boolean
>x : "foo" | "bar" | number
>"bar" : string
let b = x || y;
>b : "foo" | "bar" | number
>x || y : "foo" | "bar" | number
>x : "foo" | "bar" | number
>y : number | "foo" | "bar"
}
else {
let c = x;
>c : "foo" | "bar" | number
>x : "foo" | "bar" | number
let d = y;
>d : number | "foo" | "bar"
>y : number | "foo" | "bar"
let e: (typeof x) | (typeof y) = c || d;
>e : "foo" | "bar" | number
>x : "foo" | "bar" | number
>y : number | "foo" | "bar"
>c || d : "foo" | "bar" | number
>c : "foo" | "bar" | number
>d : number | "foo" | "bar"
}
x = y;
>x = y : number | "foo" | "bar"
>x : "foo" | "bar" | number
>y : number | "foo" | "bar"
y = x;
>y = x : "foo" | "bar" | number
>y : number | "foo" | "bar"
>x : "foo" | "bar" | number

View File

@ -7,12 +7,9 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperato
tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(13,11): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(14,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(15,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(16,9): error TS2365: Operator '<' cannot be applied to types '"ABC"' and '"XYZ"'.
tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(17,9): error TS2365: Operator '===' cannot be applied to types '"ABC"' and '"XYZ"'.
tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(18,9): error TS2365: Operator '!=' cannot be applied to types '"ABC"' and '"XYZ"'.
==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts (12 errors) ====
==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts (9 errors) ====
let abc: "ABC" = "ABC";
let xyz: "XYZ" = "XYZ";
@ -47,11 +44,5 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperato
~~~~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
let j = abc < xyz;
~~~~~~~~~
!!! error TS2365: Operator '<' cannot be applied to types '"ABC"' and '"XYZ"'.
let k = abc === xyz;
~~~~~~~~~~~
!!! error TS2365: Operator '===' cannot be applied to types '"ABC"' and '"XYZ"'.
let l = abc != xyz;
~~~~~~~~~~
!!! error TS2365: Operator '!=' cannot be applied to types '"ABC"' and '"XYZ"'.
let l = abc != xyz;