Fix mapped type instantiation circularity (#46586)

* Don't obtain constraint if doing so would cause circularity

* Add regression test

* Address CR feedback
This commit is contained in:
Anders Hejlsberg
2021-10-29 14:01:27 -07:00
committed by GitHub
parent 28e3cd3a80
commit b0ab2a54bb
6 changed files with 77 additions and 4 deletions

View File

@@ -53,4 +53,13 @@ declare function stringifyArray<T extends readonly any[]>(arr: T): { -readonly [
let abc: any[] = stringifyArray(void 0 as any);
declare function stringifyPair<T extends readonly [any, any]>(arr: T): { -readonly [K in keyof T]: string };
let def: [any, any] = stringifyPair(void 0 as any);
let def: [any, any] = stringifyPair(void 0 as any);
// Repro from #46582
type Evolvable<E extends Evolver> = {
[P in keyof E]: never;
};
type Evolver<T extends Evolvable<any> = any> = {
[key in keyof Partial<T>]: never;
};