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
jquery has batch-only inference error after re-aliasing support (##42284) #42317
Actual: Error on the argument events: "Argument of type 'string' is not assignable to parameter of type "myEvent"."
It looks like TType is inferred as "myEvent" instead of string. I can't figure out why. TType should be constrained to string | number, since its constraint as written is TType extends keyof TypeToTriggeredEventMap<TDelegateTarget, TData, TCurrentTarget, TTarget> and TypeToTriggeredEventMap has a string index signature (plus a dozen properties or so).
Changing events to "myEvent" gets rid of the error.
Mmm, nasty little issue. Problem is that the keys we compute for type instantiations need to include both the alias and the alias type arguments. I was only including the alias in the mistaken belief that the rest of the key would represent all necessary information. But it is possible (though clearly very rare) for an alias to have type arguments that map many-to-one to a single type representation--at which point we randomly pick one of them. So, only by including the alias type arguments is the key truly unique.
I the OP example, the last type parameter of JQuery.TypeEventHandler<...> is used in a manner that maps different type arguments to a single type. Thus we started confusing instantiations of the type.
Notably, this does not show up in the editor. I haven't got it to reproduce outside the jquery project either:
npm test jqueryinside Definitely Typed.tscbefore Support re-aliasing of type alias instantiations #42284 has 12 (expected) errors, whereastscafterward has 14 errors.Expected: No error on the argument
eventsActual: Error on the argument
events: "Argument of type 'string' is not assignable to parameter of type "myEvent"."It looks like TType is inferred as
"myEvent"instead ofstring. I can't figure out why. TType should be constrained tostring | number, since its constraint as written isTType extends keyof TypeToTriggeredEventMap<TDelegateTarget, TData, TCurrentTarget, TTarget>and TypeToTriggeredEventMap has a string index signature (plus a dozen properties or so).Changing
eventsto"myEvent"gets rid of the error.