We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
so we have the following convenience function:
export function asDefinedOr<T, D>(value: T | undefined, defaultValue: D): T | D { return value !== undefined ? value : defaultValue; }
we would like to prevent the following from happening
declare var x : number; asDefinedOr(x, 0); // <-- problem, unnecessary call, because x cannot be undefined
so we would like to make only T | undefined types allowed as aguments but not just T
T | undefined
T
is there a way to do it using conditional types?
so we have the following convenience function:
we would like to prevent the following from happening
so we would like to make only
T | undefinedtypes allowed as aguments but not justTis there a way to do it using conditional types?