diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes01.errors.txt b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.errors.txt deleted file mode 100644 index 14d0a892f55..00000000000 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes01.errors.txt +++ /dev/null @@ -1,33 +0,0 @@ -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(4,5): error TS2322: Type 'string' is not assignable to type '"foo" | "bar" | "baz"'. - Type 'string' is not assignable to type '"baz"'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(5,5): error TS2322: Type 'string' is not assignable to type '"foo" | "bar" | "baz"'. - Type 'string' is not assignable to type '"baz"'. - - -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts (2 errors) ==== - - type T = "foo" | "bar" | "baz"; - - var x: "foo" | "bar" | "baz" = "foo"; - ~ -!!! error TS2322: Type 'string' is not assignable to type '"foo" | "bar" | "baz"'. -!!! error TS2322: Type 'string' is not assignable to type '"baz"'. - var y: T = "bar"; - ~ -!!! error TS2322: Type 'string' is not assignable to type '"foo" | "bar" | "baz"'. -!!! error TS2322: Type 'string' is not assignable to type '"baz"'. - - if (x === "foo") { - let a = x; - } - else if (x !== "bar") { - let b = x || y; - } - else { - let c = x; - let d = y; - let e: (typeof x) | (typeof y) = c || d; - } - - x = y; - y = x; \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes01.symbols b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.symbols new file mode 100644 index 00000000000..c608929383e --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.symbols @@ -0,0 +1,52 @@ +=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts === + +type T = "foo" | "bar" | "baz"; +>T : Symbol(T, Decl(stringLiteralTypesInUnionTypes01.ts, 0, 0)) + +var x: "foo" | "bar" | "baz" = "foo"; +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes01.ts, 3, 3)) + +var y: T = "bar"; +>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes01.ts, 4, 3)) +>T : Symbol(T, Decl(stringLiteralTypesInUnionTypes01.ts, 0, 0)) + +if (x === "foo") { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes01.ts, 3, 3)) + + let a = x; +>a : Symbol(a, Decl(stringLiteralTypesInUnionTypes01.ts, 7, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes01.ts, 3, 3)) +} +else if (x !== "bar") { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes01.ts, 3, 3)) + + let b = x || y; +>b : Symbol(b, Decl(stringLiteralTypesInUnionTypes01.ts, 10, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes01.ts, 3, 3)) +>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes01.ts, 4, 3)) +} +else { + let c = x; +>c : Symbol(c, Decl(stringLiteralTypesInUnionTypes01.ts, 13, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes01.ts, 3, 3)) + + let d = y; +>d : Symbol(d, Decl(stringLiteralTypesInUnionTypes01.ts, 14, 7)) +>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes01.ts, 4, 3)) + + let e: (typeof x) | (typeof y) = c || d; +>e : Symbol(e, Decl(stringLiteralTypesInUnionTypes01.ts, 15, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes01.ts, 3, 3)) +>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes01.ts, 4, 3)) +>c : Symbol(c, Decl(stringLiteralTypesInUnionTypes01.ts, 13, 7)) +>d : Symbol(d, Decl(stringLiteralTypesInUnionTypes01.ts, 14, 7)) +} + +x = y; +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes01.ts, 3, 3)) +>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes01.ts, 4, 3)) + +y = x; +>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes01.ts, 4, 3)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes01.ts, 3, 3)) + diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes01.types b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.types new file mode 100644 index 00000000000..b5a2d876bcc --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.types @@ -0,0 +1,62 @@ +=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts === + +type T = "foo" | "bar" | "baz"; +>T : "foo" | "bar" | "baz" + +var x: "foo" | "bar" | "baz" = "foo"; +>x : "foo" | "bar" | "baz" +>"foo" : "foo" | "bar" | "baz" + +var y: T = "bar"; +>y : "foo" | "bar" | "baz" +>T : "foo" | "bar" | "baz" +>"bar" : "foo" | "bar" | "baz" + +if (x === "foo") { +>x === "foo" : boolean +>x : "foo" | "bar" | "baz" +>"foo" : string + + let a = x; +>a : "foo" | "bar" | "baz" +>x : "foo" | "bar" | "baz" +} +else if (x !== "bar") { +>x !== "bar" : boolean +>x : "foo" | "bar" | "baz" +>"bar" : string + + let b = x || y; +>b : "foo" | "bar" | "baz" +>x || y : "foo" | "bar" | "baz" +>x : "foo" | "bar" | "baz" +>y : "foo" | "bar" | "baz" +} +else { + let c = x; +>c : "foo" | "bar" | "baz" +>x : "foo" | "bar" | "baz" + + let d = y; +>d : "foo" | "bar" | "baz" +>y : "foo" | "bar" | "baz" + + let e: (typeof x) | (typeof y) = c || d; +>e : "foo" | "bar" | "baz" +>x : "foo" | "bar" | "baz" +>y : "foo" | "bar" | "baz" +>c || d : "foo" | "bar" | "baz" +>c : "foo" | "bar" | "baz" +>d : "foo" | "bar" | "baz" +} + +x = y; +>x = y : "foo" | "bar" | "baz" +>x : "foo" | "bar" | "baz" +>y : "foo" | "bar" | "baz" + +y = x; +>y = x : "foo" | "bar" | "baz" +>y : "foo" | "bar" | "baz" +>x : "foo" | "bar" | "baz" + diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types b/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types index 569edc77815..e3ac5ba4817 100644 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types @@ -5,12 +5,12 @@ type T = string | "foo" | "bar" | "baz"; var x: "foo" | "bar" | "baz" | string = "foo"; >x : "foo" | "bar" | "baz" | string ->"foo" : string +>"foo" : "foo" | "bar" | "baz" | string var y: T = "bar"; >y : string | "foo" | "bar" | "baz" >T : string | "foo" | "bar" | "baz" ->"bar" : string +>"bar" : string | "foo" | "bar" | "baz" if (x === "foo") { >x === "foo" : boolean diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes03.errors.txt b/tests/baselines/reference/stringLiteralTypesInUnionTypes03.errors.txt index 8ff377b2e72..74249b178d6 100644 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes03.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes03.errors.txt @@ -1,18 +1,13 @@ -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(5,5): error TS2322: Type 'string' is not assignable to type 'number | "foo" | "bar"'. - Type 'string' is not assignable to type '"bar"'. 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 (3 errors) ==== +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts (2 errors) ==== type T = number | "foo" | "bar"; var x: "foo" | "bar" | number; var y: T = "bar"; - ~ -!!! error TS2322: Type 'string' is not assignable to type 'number | "foo" | "bar"'. -!!! error TS2322: Type 'string' is not assignable to type '"bar"'. if (x === "foo") { ~~~~~~~~~~~ diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes04.errors.txt b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.errors.txt deleted file mode 100644 index 77cb9c09531..00000000000 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes04.errors.txt +++ /dev/null @@ -1,50 +0,0 @@ -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts(4,5): error TS2322: Type 'string' is not assignable to type '"" | "foo"'. - Type 'string' is not assignable to type '"foo"'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts(5,5): error TS2322: Type 'string' is not assignable to type '"" | "foo"'. - Type 'string' is not assignable to type '"foo"'. - - -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts (2 errors) ==== - - type T = "" | "foo"; - - let x: T = ""; - ~ -!!! error TS2322: Type 'string' is not assignable to type '"" | "foo"'. -!!! error TS2322: Type 'string' is not assignable to type '"foo"'. - let y: T = "foo"; - ~ -!!! error TS2322: Type 'string' is not assignable to type '"" | "foo"'. -!!! error TS2322: Type 'string' is not assignable to type '"foo"'. - - if (x === "") { - let a = x; - } - - if (x !== "") { - let b = x; - } - - if (x == "") { - let c = x; - } - - if (x != "") { - let d = x; - } - - if (x) { - let e = x; - } - - if (!x) { - let f = x; - } - - if (!!x) { - let g = x; - } - - if (!!!x) { - let h = x; - } \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes04.symbols b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.symbols new file mode 100644 index 00000000000..ced93fcefc9 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.symbols @@ -0,0 +1,76 @@ +=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts === + +type T = "" | "foo"; +>T : Symbol(T, Decl(stringLiteralTypesInUnionTypes04.ts, 0, 0)) + +let x: T = ""; +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) +>T : Symbol(T, Decl(stringLiteralTypesInUnionTypes04.ts, 0, 0)) + +let y: T = "foo"; +>y : Symbol(y, Decl(stringLiteralTypesInUnionTypes04.ts, 4, 3)) +>T : Symbol(T, Decl(stringLiteralTypesInUnionTypes04.ts, 0, 0)) + +if (x === "") { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) + + let a = x; +>a : Symbol(a, Decl(stringLiteralTypesInUnionTypes04.ts, 7, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) +} + +if (x !== "") { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) + + let b = x; +>b : Symbol(b, Decl(stringLiteralTypesInUnionTypes04.ts, 11, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) +} + +if (x == "") { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) + + let c = x; +>c : Symbol(c, Decl(stringLiteralTypesInUnionTypes04.ts, 15, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) +} + +if (x != "") { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) + + let d = x; +>d : Symbol(d, Decl(stringLiteralTypesInUnionTypes04.ts, 19, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) +} + +if (x) { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) + + let e = x; +>e : Symbol(e, Decl(stringLiteralTypesInUnionTypes04.ts, 23, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) +} + +if (!x) { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) + + let f = x; +>f : Symbol(f, Decl(stringLiteralTypesInUnionTypes04.ts, 27, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) +} + +if (!!x) { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) + + let g = x; +>g : Symbol(g, Decl(stringLiteralTypesInUnionTypes04.ts, 31, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) +} + +if (!!!x) { +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) + + let h = x; +>h : Symbol(h, Decl(stringLiteralTypesInUnionTypes04.ts, 35, 7)) +>x : Symbol(x, Decl(stringLiteralTypesInUnionTypes04.ts, 3, 3)) +} diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes04.types b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.types new file mode 100644 index 00000000000..9a010b490cc --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.types @@ -0,0 +1,92 @@ +=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes04.ts === + +type T = "" | "foo"; +>T : "" | "foo" + +let x: T = ""; +>x : "" | "foo" +>T : "" | "foo" +>"" : "" | "foo" + +let y: T = "foo"; +>y : "" | "foo" +>T : "" | "foo" +>"foo" : "" | "foo" + +if (x === "") { +>x === "" : boolean +>x : "" | "foo" +>"" : string + + let a = x; +>a : "" | "foo" +>x : "" | "foo" +} + +if (x !== "") { +>x !== "" : boolean +>x : "" | "foo" +>"" : string + + let b = x; +>b : "" | "foo" +>x : "" | "foo" +} + +if (x == "") { +>x == "" : boolean +>x : "" | "foo" +>"" : string + + let c = x; +>c : "" | "foo" +>x : "" | "foo" +} + +if (x != "") { +>x != "" : boolean +>x : "" | "foo" +>"" : string + + let d = x; +>d : "" | "foo" +>x : "" | "foo" +} + +if (x) { +>x : "" | "foo" + + let e = x; +>e : "" | "foo" +>x : "" | "foo" +} + +if (!x) { +>!x : boolean +>x : "" | "foo" + + let f = x; +>f : "" | "foo" +>x : "" | "foo" +} + +if (!!x) { +>!!x : boolean +>!x : boolean +>x : "" | "foo" + + let g = x; +>g : "" | "foo" +>x : "" | "foo" +} + +if (!!!x) { +>!!!x : boolean +>!!x : boolean +>!x : boolean +>x : "" | "foo" + + let h = x; +>h : "" | "foo" +>x : "" | "foo" +} diff --git a/tests/baselines/reference/stringLiteralTypesTypePredicates01.errors.txt b/tests/baselines/reference/stringLiteralTypesTypePredicates01.errors.txt index 3e412a6c770..b888c3ca77e 100644 --- a/tests/baselines/reference/stringLiteralTypesTypePredicates01.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesTypePredicates01.errors.txt @@ -1,10 +1,8 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(4,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(5,10): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts(10,5): error TS2322: Type 'string' is not assignable to type '"A" | "B"'. - Type 'string' is not assignable to type '"B"'. -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts (3 errors) ==== +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.ts (2 errors) ==== type Kind = "A" | "B" @@ -19,9 +17,6 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesTypePredicates01.t } var x: Kind = "A"; - ~ -!!! error TS2322: Type 'string' is not assignable to type '"A" | "B"'. -!!! error TS2322: Type 'string' is not assignable to type '"B"'. if (kindIs(x, "A")) { let a = x;