mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-29 16:29:19 -05:00
Infer between generic mapped types before inferring from apparent type (#56640)
This commit is contained in:
committed by
GitHub
parent
9e0e9d35b9
commit
be20dbbbbb
13
tests/cases/compiler/mappedTypeInferenceFromApparentType.ts
Normal file
13
tests/cases/compiler/mappedTypeInferenceFromApparentType.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
// @strict: true
|
||||
// @noEmit: true
|
||||
|
||||
type Obj = {
|
||||
[s: string]: number;
|
||||
};
|
||||
|
||||
type foo = <T>(target: { [K in keyof T]: T[K] }) => void;
|
||||
type bar = <U extends string[]>(source: { [K in keyof U]: Obj[K] }) => void;
|
||||
|
||||
declare let f: foo;
|
||||
declare let b: bar;
|
||||
b = f;
|
||||
13
tests/cases/compiler/mappedTypeInferenceToMappedType.ts
Normal file
13
tests/cases/compiler/mappedTypeInferenceToMappedType.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
// @strict: true
|
||||
// @noEmit: true
|
||||
|
||||
// #56133
|
||||
|
||||
declare class Base<T> {
|
||||
someProp: T;
|
||||
method<U extends unknown[]>(x: { [K in keyof U]: U[K] }): Base<U>;
|
||||
}
|
||||
|
||||
declare class Derived<T> extends Base<T> {
|
||||
method<V extends unknown[]>(x: { [K in keyof V]: V[K] }): Base<V>;
|
||||
}
|
||||
Reference in New Issue
Block a user