TypeScript/tests/cases/compiler/recursiveReverseMappedType.ts
Anders Hejlsberg a0ebd2c26e
Guard against recursion in inferTypeForHomomorphicMappedType (#38224)
* Guard against recursion in inferTypeForHomomorphicMappedType

* Add regression test
2020-04-28 16:56:35 -07:00

16 lines
331 B
TypeScript

// @strict: true
// Repro from #38198
type Recur<T> = (
T extends (unknown[]) ? {} : { [K in keyof T]?: Recur<T[K]> }
) | ['marker', ...Recur<T>[]];
function join<T>(l: Recur<T>[]): Recur<T> {
return ['marker', ...l];
}
function a<T>(l: Recur<T>[]): void {
const x: Recur<T> | undefined = join(l);
}