Skip to content

Commit 70763da

Browse files
committed
Add regression test
1 parent 523aca2 commit 70763da

File tree

4 files changed

+139
-0
lines changed

4 files changed

+139
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//// [mappedTypeNestedGenericInstantiation.ts]
2+
// Repro from #13346
3+
4+
interface Chainable<T> {
5+
value(): T;
6+
mapValues<U>(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>;
7+
}
8+
9+
declare function chain<T>(t: T): Chainable<T>;
10+
11+
const square = (x: number) => x * x;
12+
13+
const v = chain({a: 1, b: 2}).mapValues(square).value();
14+
15+
16+
//// [mappedTypeNestedGenericInstantiation.js]
17+
// Repro from #13346
18+
var square = function (x) { return x * x; };
19+
var v = chain({ a: 1, b: 2 }).mapValues(square).value();
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
=== tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts ===
2+
// Repro from #13346
3+
4+
interface Chainable<T> {
5+
>Chainable : Symbol(Chainable, Decl(mappedTypeNestedGenericInstantiation.ts, 0, 0))
6+
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20))
7+
8+
value(): T;
9+
>value : Symbol(Chainable.value, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 24))
10+
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20))
11+
12+
mapValues<U>(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>;
13+
>mapValues : Symbol(Chainable.mapValues, Decl(mappedTypeNestedGenericInstantiation.ts, 3, 13))
14+
>U : Symbol(U, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 12))
15+
>func : Symbol(func, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 15))
16+
>v : Symbol(v, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 22))
17+
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20))
18+
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20))
19+
>U : Symbol(U, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 12))
20+
>Chainable : Symbol(Chainable, Decl(mappedTypeNestedGenericInstantiation.ts, 0, 0))
21+
>k : Symbol(k, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 56))
22+
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20))
23+
>U : Symbol(U, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 12))
24+
}
25+
26+
declare function chain<T>(t: T): Chainable<T>;
27+
>chain : Symbol(chain, Decl(mappedTypeNestedGenericInstantiation.ts, 5, 1))
28+
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 23))
29+
>t : Symbol(t, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 26))
30+
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 23))
31+
>Chainable : Symbol(Chainable, Decl(mappedTypeNestedGenericInstantiation.ts, 0, 0))
32+
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 23))
33+
34+
const square = (x: number) => x * x;
35+
>square : Symbol(square, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 5))
36+
>x : Symbol(x, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 16))
37+
>x : Symbol(x, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 16))
38+
>x : Symbol(x, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 16))
39+
40+
const v = chain({a: 1, b: 2}).mapValues(square).value();
41+
>v : Symbol(v, Decl(mappedTypeNestedGenericInstantiation.ts, 11, 5))
42+
>chain({a: 1, b: 2}).mapValues(square).value : Symbol(Chainable.value, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 24))
43+
>chain({a: 1, b: 2}).mapValues : Symbol(Chainable.mapValues, Decl(mappedTypeNestedGenericInstantiation.ts, 3, 13))
44+
>chain : Symbol(chain, Decl(mappedTypeNestedGenericInstantiation.ts, 5, 1))
45+
>a : Symbol(a, Decl(mappedTypeNestedGenericInstantiation.ts, 11, 17))
46+
>b : Symbol(b, Decl(mappedTypeNestedGenericInstantiation.ts, 11, 22))
47+
>mapValues : Symbol(Chainable.mapValues, Decl(mappedTypeNestedGenericInstantiation.ts, 3, 13))
48+
>square : Symbol(square, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 5))
49+
>value : Symbol(Chainable.value, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 24))
50+
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
=== tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts ===
2+
// Repro from #13346
3+
4+
interface Chainable<T> {
5+
>Chainable : Chainable<T>
6+
>T : T
7+
8+
value(): T;
9+
>value : () => T
10+
>T : T
11+
12+
mapValues<U>(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>;
13+
>mapValues : <U>(func: (v: T[keyof T]) => U) => Chainable<{ [k in keyof T]: U; }>
14+
>U : U
15+
>func : (v: T[keyof T]) => U
16+
>v : T[keyof T]
17+
>T : T
18+
>T : T
19+
>U : U
20+
>Chainable : Chainable<T>
21+
>k : k
22+
>T : T
23+
>U : U
24+
}
25+
26+
declare function chain<T>(t: T): Chainable<T>;
27+
>chain : <T>(t: T) => Chainable<T>
28+
>T : T
29+
>t : T
30+
>T : T
31+
>Chainable : Chainable<T>
32+
>T : T
33+
34+
const square = (x: number) => x * x;
35+
>square : (x: number) => number
36+
>(x: number) => x * x : (x: number) => number
37+
>x : number
38+
>x * x : number
39+
>x : number
40+
>x : number
41+
42+
const v = chain({a: 1, b: 2}).mapValues(square).value();
43+
>v : { a: number; b: number; }
44+
>chain({a: 1, b: 2}).mapValues(square).value() : { a: number; b: number; }
45+
>chain({a: 1, b: 2}).mapValues(square).value : () => { a: number; b: number; }
46+
>chain({a: 1, b: 2}).mapValues(square) : Chainable<{ a: number; b: number; }>
47+
>chain({a: 1, b: 2}).mapValues : <U>(func: (v: number) => U) => Chainable<{ a: U; b: U; }>
48+
>chain({a: 1, b: 2}) : Chainable<{ a: number; b: number; }>
49+
>chain : <T>(t: T) => Chainable<T>
50+
>{a: 1, b: 2} : { a: number; b: number; }
51+
>a : number
52+
>1 : 1
53+
>b : number
54+
>2 : 2
55+
>mapValues : <U>(func: (v: number) => U) => Chainable<{ a: U; b: U; }>
56+
>square : (x: number) => number
57+
>value : () => { a: number; b: number; }
58+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Repro from #13346
2+
3+
interface Chainable<T> {
4+
value(): T;
5+
mapValues<U>(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>;
6+
}
7+
8+
declare function chain<T>(t: T): Chainable<T>;
9+
10+
const square = (x: number) => x * x;
11+
12+
const v = chain({a: 1, b: 2}).mapValues(square).value();

0 commit comments

Comments
 (0)