Fix non-homomorphic mapped type constraint issues (#41807)

* Less aggressive wildcard check, 'keyof any' constraint for 'infer T' in mapped type constraint position

* Accept new baselines

* Add regression tests
This commit is contained in:
Anders Hejlsberg
2020-12-03 18:36:45 -08:00
committed by GitHub
parent 143d1104ab
commit cd37a327a7
6 changed files with 128 additions and 7 deletions

View File

@@ -79,3 +79,15 @@ type ListChild = Child<ListWidget>
declare let x: ListChild;
x.type;
// Repros from #41790
export type TV<T, K extends keyof T> = T[K] extends Record<infer E, any> ? E : never;
export type ObjectOrArray<T, K extends keyof any = keyof any> = T[] | Record<K, T | Record<K, T> | T[]>;
export type ThemeValue<K extends keyof ThemeType, ThemeType, TVal = any> =
ThemeType[K] extends TVal[] ? number :
ThemeType[K] extends Record<infer E, TVal> ? E :
ThemeType[K] extends ObjectOrArray<infer F> ? F : never;
export type Foo<T> = T extends { [P in infer E]: any } ? E : never;