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
interfaceOptions<K>{key: K;fn(key: K): any;}functionid<K>(options: ()=>Options<K>){throw'unimplemented';}constbreaks=id(()=>{return{key: {id: 32},fn(key){// 'key' is of type 'unknown'.(18046)returnkey.id.toString();},};});constworks=id(()=>({key: {id: 32},fn(key){returnkey.id.toString();},}));
๐ Actual behavior
The fn parameter type is only correctly inferred in the case where an arrow function is directly returning an object.
๐ Expected behavior
I would expect for both cases to be handled consistently.
The text was updated successfully, but these errors were encountered:
@RyanCavanaugh Is a block body context sensitive in a way that a concise body isnโt? I suspect as much but Iโd love to hear official word since #47599 doesnโt seem to talk about that specifically.
Bug Report
๐ Search Terms
contextual type inference function return generic
๐ Version & Regression Information
โฏ Playground Link
Playground link with relevant code
๐ป Code
๐ Actual behavior
The
fn
parameter type is only correctly inferred in the case where an arrow function is directly returning an object.๐ Expected behavior
I would expect for both cases to be handled consistently.
The text was updated successfully, but these errors were encountered: