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
The call/apply mechanics end up going through the arg-to-tuple process, which isn't capable of handling overloads. Since your return types match, you can write
interfaceFn{(...args: [string]|[number,boolean]): void;}declareconstf: Fn;f('');// okf.call(null,'');// okf.apply(null,['']);// ok
Thanks for explaining, this is not a major issue for us, just wanted to check if it can use a small bug fix, or a known design limitation. Feel free to close this issue.
TypeScript Version: 3.8.2-dev.201xxxxx
Search Terms: call apply overload
Code
Expected behavior:
No type errors as
f('')
is equivalent tof.call(null, '')
andf.apply(null, [''])
.Actual behavior:
Type errors on
f.call(null, '')
andf.apply(null, [''])
.Playground Link: Playground Link
Related Issues:
The text was updated successfully, but these errors were encountered: