You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typeConditionalType<T>=Textendsstring ? string : number;functionConditionalOrUndefined<T>() : ConditionalType<T>|undefined{return0asany;}functionJustConditional<T>() : ConditionalType<T>{returnConditionalOrUndefined<T>()!;// Type 'NonNullable<ConditionalType<T>>' is not assignable to type 'ConditionalType<T>'}// For comparison...functiongenericOrUndefined<T>() : T|undefined{return0asany;}functionJustGeneric<T>(): T{returngenericOrUndefined<T>()!;// no error}
Expected behavior:
JustConditional compiles without errors, like JustGeneric.
Actual behavior:
JustConditional produces error Type 'NonNullable<ConditionalType<T>>' is not assignable to type 'ConditionalType<T>'
TypeScript Version: typescript@3.4.0-dev.20190330
Search Terms: Conditional NonNullable Type
Code
Expected behavior:
JustConditional compiles without errors, like JustGeneric.
Actual behavior:
JustConditional produces error
Type 'NonNullable<ConditionalType<T>>' is not assignable to type 'ConditionalType<T>'Playground Link:
https://typescript-play.js.org/?target=2#code/C4TwDgpgBAwg9gOwCYEtgsQQwDYBVwQA8uAfFALxS5QQAewEyAzlE8AE4oIDmUA-Kw5deALigIArgFsARhHZQA3AChlAMwkIAxukSxEqXQhwB5dgFVkENVwhJiJABQBKKGPjI0GY3gIOoAD5QmkjWtkhQAN7KULFQ7BDAEuwIUAAMUJgsmAggKgC+qhraRlAAUhJsHobeOA4ubvqeRjj4kP7RcfGJyanVXljYZpahNgh29c4AhIpQAPRzVARQAOQAcohrEtjYmDLYRP0tvu2kJCtQKCwIcMCZTEwo3Mb70MBwUKCQq0e1J0SkFbKQqqBZQABicAUWjgUjAmE4TEQADpUUVNDpvFBuIx5CgtMMrGMJqQGmJqEEQmFxhFOnEEkkUul7plcgV0SUsRU2ABxXGcLSTclRGL0npMnHjAWE0bhSYzeaLG40djsKHAoA
Related Issues:
It looks like NonNullable has had similar issues with other complex types:
#23849
#27456