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
interfaceSubscribeFieldOptions<Event>{subscribe: ()=>Eventresolve: (event: Event)=>number}declarefunctiondefineOptions<Event>(options: SubscribeFieldOptions<Event>,): voiddefineOptions({// error: Type 'unknown' is not assignable to type 'number'resolve: (event)=>event,subscribe(){return123},})// error: Type 'unknown' is not assignable to type 'number'defineOptions({resolve: (event)=>event,subscribe: function(){return123},})// no error when property order is swapped:defineOptions({subscribe(){return123},resolve: (event)=>event,})// no error when using arrow function for `subscribe`:defineOptions({resolve: (event)=>event,subscribe: ()=>{return123},})
🙁 Actual behavior
The event argument is inferred as unknown when using a the resolve method is defined before the subscribe method in the defineOptions call, and resolve is a function, async function, function* or async function*
🙂 Expected behavior
The event argument of the resolve function should be correctly inferred regardless of what kind of function definition is used (arrow, method, function, async function, generator, async generator)
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered:
🔎 Search Terms
inference infer order function arguments
🕗 Version & Regression Information
This affects all tested version of typescript back to 3.3.3 (oldest version available in the playground)
In 5.0 the started to only affect function using the
function
keyword, arrow functions and object methods are no-longer affected after 5.0after 5.0 functions using the
function
keyword are still affected (functions, generators, and async generators)⏯ Playground Link
https://www.typescriptlang.org/play/?target=11#code/JYOwLgpgTgZghgYwgAgMoFcBGBnBViYQBiwEANgCYDyADmMAPYjYA8AogG4TgB8yA3gChkybFlz5CALmQAKAJTIAvH07cww5FAjYGZLjNkQu4GWvCKVyEOgC2hKIIC+gwRQgIycbchjoQCPRMyO4woBC0QczsJmA8spoMdIzMMhg4eATEpJSRKazmcQA0gvIyHAzAFK4A9DXI0FAMUFJuEGEgEclM2LJCItq6+hCGxuqWfGPgJSJiGZIQCgJaEGDoUCDIAIwATADMyE4lTvK19Y3NraHheT19moN6BnJTYBMNsTOi4pnSvv6BFJLfgrNYbbb7Q7HU6COrWBgNKBNKDIADuAAtuMgaE0aNAwABPZDNdwo4DYUSouA0PEUK7tG7dZj3WY-BbA0HrTa7A5HB46J4jF6xd6vaFneGI5FozGbdDYUAAc2Q3iaqP+ASivmayAABnMJFldfSOl0or1+ishs8jCLlJNPpoDb8hUsrCDtGDuZC+ScgA
💻 Code
🙁 Actual behavior
The
event
argument is inferred asunknown
when using a theresolve
method is defined before thesubscribe
method in the defineOptions call, andresolve
is afunction
,async function
,function*
orasync function*
🙂 Expected behavior
The
event
argument of theresolve
function should be correctly inferred regardless of what kind of function definition is used (arrow, method, function, async function, generator, async generator)Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: