Overloaded function with at least one generic overload can be assigned to any function with at least the same number of parameters · Issue #50050 · microsoft/TypeScript · GitHub
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
// only overloadedfunctiona(value: string): void;functiona(value: number): void;functiona(value: string|number){value.toString()};// only genericfunctionb<Textendsnumber>(value: T): void{value.toString()};// overloaded with genericfunctionc(value: string): void;functionc<Textendsnumber>(value: T): void;functionc(value: string|number){value.toString()};// these are errors as expected()=>{letd: (value: unknown)=>void=a;lete: (value: unknown)=>void=b;c(null);}// this should be an errorletf: (value: unknown)=>void=c;f(null);
🙁 Actual behavior
In the example above I call f(null) and cause a runtime error, however typescript doesn't warn me about it.
🙂 Expected behavior
c should not be assignable to (value: unknown) => void.