// @strict: true // from https://github.com/microsoft/TypeScript/issues/30706 type ConditionalType = T extends string ? string : number; function ConditionalOrUndefined(): ConditionalType | undefined { return 0 as any; } function JustConditional(): ConditionalType { return ConditionalOrUndefined()!; // shouldn't error } // For comparison... function genericOrUndefined(): T | undefined { return 0 as any; } function JustGeneric(): T { return genericOrUndefined()!; // no error } // Simplified example: function f() { type One = T extends string ? string : string; type A = T extends number ? One : never; const x: One = null as any as A; }