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
declarefunctionoverload(param: number);declarefunctionoverload(param: string);letbar: number|string;overload(bar);// Argument of type 'number' | 'string' is not assignable to parameter of type 'string'
Expected behavior:
Since the function 'overload' either accepts a 'number' or a 'string', the compiler should not complain.
Actual behavior:
The compiler complains with: "Argument of type 'number' | 'string' is not assignable to parameter of type 'string'".
Workaround:
Of course I could always rewrite the declaration of 'overload' as:
declarefunctionoverload(param: number|string);
But usually these declarations are from external *.d.ts files which I do not want to touch if I don't have to.
The text was updated successfully, but these errors were encountered:
TypeScript Version:
1.8.10
Code
Expected behavior:
Since the function 'overload' either accepts a 'number' or a 'string', the compiler should not complain.
Actual behavior:
The compiler complains with: "Argument of type 'number' | 'string' is not assignable to parameter of type 'string'".
Workaround:
Of course I could always rewrite the declaration of 'overload' as:
But usually these declarations are from external *.d.ts files which I do not want to touch if I don't have to.
The text was updated successfully, but these errors were encountered: