mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
Add regression test
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
//// [mappedTypeNestedGenericInstantiation.ts]
|
||||
// Repro from #13346
|
||||
|
||||
interface Chainable<T> {
|
||||
value(): T;
|
||||
mapValues<U>(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>;
|
||||
}
|
||||
|
||||
declare function chain<T>(t: T): Chainable<T>;
|
||||
|
||||
const square = (x: number) => x * x;
|
||||
|
||||
const v = chain({a: 1, b: 2}).mapValues(square).value();
|
||||
|
||||
|
||||
//// [mappedTypeNestedGenericInstantiation.js]
|
||||
// Repro from #13346
|
||||
var square = function (x) { return x * x; };
|
||||
var v = chain({ a: 1, b: 2 }).mapValues(square).value();
|
||||
@@ -0,0 +1,50 @@
|
||||
=== tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts ===
|
||||
// Repro from #13346
|
||||
|
||||
interface Chainable<T> {
|
||||
>Chainable : Symbol(Chainable, Decl(mappedTypeNestedGenericInstantiation.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20))
|
||||
|
||||
value(): T;
|
||||
>value : Symbol(Chainable.value, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 24))
|
||||
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20))
|
||||
|
||||
mapValues<U>(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>;
|
||||
>mapValues : Symbol(Chainable.mapValues, Decl(mappedTypeNestedGenericInstantiation.ts, 3, 13))
|
||||
>U : Symbol(U, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 12))
|
||||
>func : Symbol(func, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 15))
|
||||
>v : Symbol(v, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 22))
|
||||
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20))
|
||||
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20))
|
||||
>U : Symbol(U, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 12))
|
||||
>Chainable : Symbol(Chainable, Decl(mappedTypeNestedGenericInstantiation.ts, 0, 0))
|
||||
>k : Symbol(k, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 56))
|
||||
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20))
|
||||
>U : Symbol(U, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 12))
|
||||
}
|
||||
|
||||
declare function chain<T>(t: T): Chainable<T>;
|
||||
>chain : Symbol(chain, Decl(mappedTypeNestedGenericInstantiation.ts, 5, 1))
|
||||
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 23))
|
||||
>t : Symbol(t, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 26))
|
||||
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 23))
|
||||
>Chainable : Symbol(Chainable, Decl(mappedTypeNestedGenericInstantiation.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 23))
|
||||
|
||||
const square = (x: number) => x * x;
|
||||
>square : Symbol(square, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 5))
|
||||
>x : Symbol(x, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 16))
|
||||
>x : Symbol(x, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 16))
|
||||
>x : Symbol(x, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 16))
|
||||
|
||||
const v = chain({a: 1, b: 2}).mapValues(square).value();
|
||||
>v : Symbol(v, Decl(mappedTypeNestedGenericInstantiation.ts, 11, 5))
|
||||
>chain({a: 1, b: 2}).mapValues(square).value : Symbol(Chainable.value, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 24))
|
||||
>chain({a: 1, b: 2}).mapValues : Symbol(Chainable.mapValues, Decl(mappedTypeNestedGenericInstantiation.ts, 3, 13))
|
||||
>chain : Symbol(chain, Decl(mappedTypeNestedGenericInstantiation.ts, 5, 1))
|
||||
>a : Symbol(a, Decl(mappedTypeNestedGenericInstantiation.ts, 11, 17))
|
||||
>b : Symbol(b, Decl(mappedTypeNestedGenericInstantiation.ts, 11, 22))
|
||||
>mapValues : Symbol(Chainable.mapValues, Decl(mappedTypeNestedGenericInstantiation.ts, 3, 13))
|
||||
>square : Symbol(square, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 5))
|
||||
>value : Symbol(Chainable.value, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 24))
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
=== tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts ===
|
||||
// Repro from #13346
|
||||
|
||||
interface Chainable<T> {
|
||||
>Chainable : Chainable<T>
|
||||
>T : T
|
||||
|
||||
value(): T;
|
||||
>value : () => T
|
||||
>T : T
|
||||
|
||||
mapValues<U>(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>;
|
||||
>mapValues : <U>(func: (v: T[keyof T]) => U) => Chainable<{ [k in keyof T]: U; }>
|
||||
>U : U
|
||||
>func : (v: T[keyof T]) => U
|
||||
>v : T[keyof T]
|
||||
>T : T
|
||||
>T : T
|
||||
>U : U
|
||||
>Chainable : Chainable<T>
|
||||
>k : k
|
||||
>T : T
|
||||
>U : U
|
||||
}
|
||||
|
||||
declare function chain<T>(t: T): Chainable<T>;
|
||||
>chain : <T>(t: T) => Chainable<T>
|
||||
>T : T
|
||||
>t : T
|
||||
>T : T
|
||||
>Chainable : Chainable<T>
|
||||
>T : T
|
||||
|
||||
const square = (x: number) => x * x;
|
||||
>square : (x: number) => number
|
||||
>(x: number) => x * x : (x: number) => number
|
||||
>x : number
|
||||
>x * x : number
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
const v = chain({a: 1, b: 2}).mapValues(square).value();
|
||||
>v : { a: number; b: number; }
|
||||
>chain({a: 1, b: 2}).mapValues(square).value() : { a: number; b: number; }
|
||||
>chain({a: 1, b: 2}).mapValues(square).value : () => { a: number; b: number; }
|
||||
>chain({a: 1, b: 2}).mapValues(square) : Chainable<{ a: number; b: number; }>
|
||||
>chain({a: 1, b: 2}).mapValues : <U>(func: (v: number) => U) => Chainable<{ a: U; b: U; }>
|
||||
>chain({a: 1, b: 2}) : Chainable<{ a: number; b: number; }>
|
||||
>chain : <T>(t: T) => Chainable<T>
|
||||
>{a: 1, b: 2} : { a: number; b: number; }
|
||||
>a : number
|
||||
>1 : 1
|
||||
>b : number
|
||||
>2 : 2
|
||||
>mapValues : <U>(func: (v: number) => U) => Chainable<{ a: U; b: U; }>
|
||||
>square : (x: number) => number
|
||||
>value : () => { a: number; b: number; }
|
||||
|
||||
12
tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts
Normal file
12
tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
// Repro from #13346
|
||||
|
||||
interface Chainable<T> {
|
||||
value(): T;
|
||||
mapValues<U>(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>;
|
||||
}
|
||||
|
||||
declare function chain<T>(t: T): Chainable<T>;
|
||||
|
||||
const square = (x: number) => x * x;
|
||||
|
||||
const v = chain({a: 1, b: 2}).mapValues(square).value();
|
||||
Reference in New Issue
Block a user