Skip to content

Commit 18b5ade

Browse files
committed
Add regression test
1 parent 6911acf commit 18b5ade

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//// [freshLiteralTypesInIntersections.ts]
2+
// Repro from #19657
3+
4+
declare function func<A extends string, B extends A>(a: A, b: B[]): (ab: A & B) => void;
5+
const q = func("x" as "x" | "y", ["x"]);
6+
q("x");
7+
8+
9+
//// [freshLiteralTypesInIntersections.js]
10+
"use strict";
11+
// Repro from #19657
12+
var q = func("x", ["x"]);
13+
q("x");
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
=== tests/cases/compiler/freshLiteralTypesInIntersections.ts ===
2+
// Repro from #19657
3+
4+
declare function func<A extends string, B extends A>(a: A, b: B[]): (ab: A & B) => void;
5+
>func : Symbol(func, Decl(freshLiteralTypesInIntersections.ts, 0, 0))
6+
>A : Symbol(A, Decl(freshLiteralTypesInIntersections.ts, 2, 22))
7+
>B : Symbol(B, Decl(freshLiteralTypesInIntersections.ts, 2, 39))
8+
>A : Symbol(A, Decl(freshLiteralTypesInIntersections.ts, 2, 22))
9+
>a : Symbol(a, Decl(freshLiteralTypesInIntersections.ts, 2, 53))
10+
>A : Symbol(A, Decl(freshLiteralTypesInIntersections.ts, 2, 22))
11+
>b : Symbol(b, Decl(freshLiteralTypesInIntersections.ts, 2, 58))
12+
>B : Symbol(B, Decl(freshLiteralTypesInIntersections.ts, 2, 39))
13+
>ab : Symbol(ab, Decl(freshLiteralTypesInIntersections.ts, 2, 69))
14+
>A : Symbol(A, Decl(freshLiteralTypesInIntersections.ts, 2, 22))
15+
>B : Symbol(B, Decl(freshLiteralTypesInIntersections.ts, 2, 39))
16+
17+
const q = func("x" as "x" | "y", ["x"]);
18+
>q : Symbol(q, Decl(freshLiteralTypesInIntersections.ts, 3, 5))
19+
>func : Symbol(func, Decl(freshLiteralTypesInIntersections.ts, 0, 0))
20+
21+
q("x");
22+
>q : Symbol(q, Decl(freshLiteralTypesInIntersections.ts, 3, 5))
23+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
=== tests/cases/compiler/freshLiteralTypesInIntersections.ts ===
2+
// Repro from #19657
3+
4+
declare function func<A extends string, B extends A>(a: A, b: B[]): (ab: A & B) => void;
5+
>func : <A extends string, B extends A>(a: A, b: B[]) => (ab: A & B) => void
6+
>A : A
7+
>B : B
8+
>A : A
9+
>a : A
10+
>A : A
11+
>b : B[]
12+
>B : B
13+
>ab : A & B
14+
>A : A
15+
>B : B
16+
17+
const q = func("x" as "x" | "y", ["x"]);
18+
>q : (ab: "x") => void
19+
>func("x" as "x" | "y", ["x"]) : (ab: "x") => void
20+
>func : <A extends string, B extends A>(a: A, b: B[]) => (ab: A & B) => void
21+
>"x" as "x" | "y" : "x" | "y"
22+
>"x" : "x"
23+
>["x"] : "x"[]
24+
>"x" : "x"
25+
26+
q("x");
27+
>q("x") : void
28+
>q : (ab: "x") => void
29+
>"x" : "x"
30+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// @strict: true
2+
3+
// Repro from #19657
4+
5+
declare function func<A extends string, B extends A>(a: A, b: B[]): (ab: A & B) => void;
6+
const q = func("x" as "x" | "y", ["x"]);
7+
q("x");

0 commit comments

Comments
 (0)