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
typeOptions<TContext>={onStart?: ()=>TContextonEnd?: (context: TContext)=>void}functioncreate<TContext>(builder: (arg: boolean)=>Options<TContext>){returnbuilder(true)}// Workscreate((arg: boolean)=>({onStart: ()=>({time: newDate()}),onEnd: (context)=>console.log(context.time)}))// Workscreate(()=>({onStart: ()=>({time: newDate()}),onEnd: (context)=>console.log(context.time)}))// Fails!create((arg)=>({onStart: ()=>({time: newDate()}),onEnd: (context)=>console.log(context.time)// Error: 'context' is of type 'unknown'}))
π Actual behavior
The value of TContext is not inferred properly when an parameter is included in the builder function. Removing the argument resolves the issue, as does adding an explicit type for the argument.
π Expected behavior
The value of TContext should be inferred properly, regardless of if a parameter is included in the builder function, or if the parameter has or does not have an explicit type.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered:
I think this is a duplicate of this closed issue: #57021 . I have an experimental branch lying around somewhere that could address - I'll try to revamp it and push out soon-ish
π Search Terms
function parameter inference
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?#code/C4TwDgpgBA8mwEsD2A7AzgHgCoGFXAgA9gA+KAXigG8BYAKCilQGVgBDAJ2AH4AuKABQBKCmVz4iweo1QBRFABM+ggMYTi-cSgLER5MgDckCBfQC+9egDMArihWJUUFRwhsC2PNskkBAIxsEABsFCA5+AU4Ac34-JCQgtxQ9MjhHdE91UhFaBihXYBsOFCgA4NCOAWAOGwghc0s6AHomqAB1JA4AazR6FzcCAUiOGNL4xLZk0UFcmRRWTmAIlJmoRABbCH4UCAB3KAARdwhhKDMhABppJhR5BQi1b11p2cZnVDQEiAA6IKQogSPHTAb4bOrXMxXOjnep0egtdqdHp9VzHIYrASvFjsLjLaaYtYITbbPaHNEic5QuZ3B5ZFavRiPT6JX7-QFZUFE8F5SHmISw+GtABibGCaAAhCiBidhlEMVj5jiloJ5YTiVAdvsjoMKZdrnJFLSnsB6ddGR8vqyAUDJJzNiIEbIOBxOvwAOQ24huqAINBMKxrcDQN12LooJC7FBuiFQmH0IA
π» Code
π Actual behavior
The value of
TContext
is not inferred properly when an parameter is included in the builder function. Removing the argument resolves the issue, as does adding an explicit type for the argument.π Expected behavior
The value of
TContext
should be inferred properly, regardless of if a parameter is included in the builder function, or if the parameter has or does not have an explicit type.Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: