1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
// @strict: true
// @noEmit: true
type C1<T> = T extends unknown ? T | undefined : never;
type C2<T> = T extends unknown ? T | undefined : never;
type C3<T> = T extends unknown ? T | undefined : never;
type C4<T> = T extends unknown ? T | undefined : never;
declare function f0<T>(x: T): [T];
declare function f1<T>(x: C1<T>): [T];
declare function f2<T>(x: C1<C2<T>>): [T];
declare function f3<T>(x: C1<C2<C3<T>>>): [T];
declare function f4<T>(x: C1<C2<C3<C4<T>>>>): [T];
const c0 = f0(7); // [number]
const c1 = f1(7); // [number]
const c2 = f2(7); // [number]
const c3 = f3(7); // [number]
const c4 = f4(7); // [7] since we have an internal nesting limit of 3
// Repro from #52620
class FormControl<T> {
constructor(t: T extends undefined ? never : T) {}
}
const a = new FormControl(''); // string
class FormControl2<T> {
constructor(t: T | string) {}
}
const b = new FormControl2(''); // string
class FormControl3<T> {
constructor(t: T extends undefined ? never : T | string) {}
}
const c = new FormControl3(''); // string
|