diff --git a/tests/baselines/reference/stringLiteralTypesAndLogicalOrExpressions01.js b/tests/baselines/reference/stringLiteralTypesAndLogicalOrExpressions01.js new file mode 100644 index 00000000000..479256b18b7 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesAndLogicalOrExpressions01.js @@ -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"; diff --git a/tests/baselines/reference/stringLiteralTypesAndLogicalOrExpressions01.symbols b/tests/baselines/reference/stringLiteralTypesAndLogicalOrExpressions01.symbols new file mode 100644 index 00000000000..2a9f28e85a5 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesAndLogicalOrExpressions01.symbols @@ -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)) + diff --git a/tests/baselines/reference/stringLiteralTypesAndLogicalOrExpressions01.types b/tests/baselines/reference/stringLiteralTypesAndLogicalOrExpressions01.types new file mode 100644 index 00000000000..ddc79b81857 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesAndLogicalOrExpressions01.types @@ -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" + diff --git a/tests/baselines/reference/stringLiteralTypesAndParenthesizedExpressions01.errors.txt b/tests/baselines/reference/stringLiteralTypesAndParenthesizedExpressions01.errors.txt new file mode 100644 index 00000000000..93d8a213d0f --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesAndParenthesizedExpressions01.errors.txt @@ -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")); + \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesAndParenthesizedExpressions01.js b/tests/baselines/reference/stringLiteralTypesAndParenthesizedExpressions01.js new file mode 100644 index 00000000000..1fe1225c6f4 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesAndParenthesizedExpressions01.js @@ -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"; diff --git a/tests/baselines/reference/stringLiteralTypesOverloads04.js b/tests/baselines/reference/stringLiteralTypesOverloads04.js new file mode 100644 index 00000000000..fd10ac986a9 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesOverloads04.js @@ -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; diff --git a/tests/baselines/reference/stringLiteralTypesOverloads04.symbols b/tests/baselines/reference/stringLiteralTypesOverloads04.symbols new file mode 100644 index 00000000000..9f468b8bd95 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesOverloads04.symbols @@ -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)) + +}) diff --git a/tests/baselines/reference/stringLiteralTypesOverloads04.types b/tests/baselines/reference/stringLiteralTypesOverloads04.types new file mode 100644 index 00000000000..32d316494ca --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesOverloads04.types @@ -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" + +})