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
{{ message }}
Repository navigation
Cannot mix both fixed and rest arguments using '.call' when using '--strictBindCallApply' #37834
The bind error case is likely a design limitation until we can represent spreading a non-array-type in a tuple type, i.e. [T, ...U] (if U has an array or tuple type as a base constraint).
We could possibly resolve the call error case by adding a few overloads.
The above call reports an error without the overloads: error TS2554: Expected 3 arguments, but got 4., but with the overloads we infer a function type that has the excess argument A3 and foo is assignable to that type so we don't report an error.
Activity
rbuckton commentedon Apr 8, 2020
The
binderror case is likely a design limitation until we can represent spreading a non-array-type in a tuple type, i.e.[T, ...U](ifUhas an array or tuple type as a base constraint).We could possibly resolve the
callerror case by adding a few overloads.rbuckton commentedon Apr 8, 2020
The
bindcase could also be partially resolved by specifying a fixed set of unbound type arguments, i.e.:This is similar to the existing
bind<T, A0, A extends any[], R>overload, except that it passes onarg0and allows us to have the fixed argument list.rbuckton commentedon Apr 8, 2020
Unfortunately, just adding overloads doesn't address this. I added these to
calland ended up with cases that should be errors compiling successfully:From
tests\cases\conformance\functions\strictBindCallApply1.ts:The above call reports an error without the overloads:
error TS2554: Expected 3 arguments, but got 4., but with the overloads we infer a function type that has the excess argumentA3andfoois assignable to that type so we don't report an error.