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
it would be nice if you could rely on function overloads to more easily narrow parameters
π Motivating Example
in this case, it's impossible for value2 to be undefined if value1 isn't
functionfoo(): voidfunctionfoo(value1: number,value2: number): voidfunctionfoo(value1?: number,value2?: number): void{if(typeofvalue1!=='undefined'){//Type 'number | undefined' is not assignable to type 'number'.// Type 'undefined' is not assignable to type 'number'.(2322)constbar: number=value2}}
The text was updated successfully, but these errors were encountered:
Suggestion
π Search Terms
overload narrowing
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
it would be nice if you could rely on function overloads to more easily narrow parameters
π Motivating Example
in this case, it's impossible for
value2
to be undefined ifvalue1
isn'tThe text was updated successfully, but these errors were encountered: