🔎 Search Terms
Unable to get generic type, arrow function
🕗 Version & Regression Information
- This is a crash
- This problem exists in Nightly version
- This is the behavior in every version I tried
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.2.2#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXzDigxAB4AoeK+AZQ2IRAA8TVgBneAJXBxmFLsMMLKgDmAGnhRUATwB8EytQAixKPGasO3Xv0HDRk6XMXKqAQUy5UnLSDacAFEIYAuWvRJTg6j2voASngAXnldMD4BIRFxKRkFJXknWDF2DwBvczEQDDp3eCdgsM8GAG5zKGs8dPgrbBqK6hyMAKgPItDwtoqAX0CPADccLGAK8kIQBics6ngW-JJO2bnqOAxkGHwM6Q8ARnhe80OlOZa2juLwldX4dc3t+AAjDwAmQ+Pe0+oqhtsXLwgHzqYI3VauEjHOYAemh8AAegB+KHUXz0FFUWEI5G3Kj3LbwMG4+AAL32GI+cyO-SAA
💻 Code
declarefunctioncreate<StateextendsRecord<string,any>,DataextendsRecord<string,any>,Actionsextends(state: State,data: Data)=>Record<string,any>,>(args: {getState: ()=>State;actions: Actions;getData: ()=>Data;}): void;create({getState(){return{a: 1}},getData: ()=>{return{b: 2}},actions(state,data){state// ^?data// ^?return{z: 1}}})🙁 Actual behavior
The getState and getData function types need to be consistent. For example, they are both arrow functions or ordinary functions to correctly infer the type. Otherwise, they cannot
🙂 Expected behavior
No matter what type of functions getState and getData are, the types can be correctly inferred in the actions function parameters.
Additional information about the issue
No response
🔎 Search Terms
Unable to get generic type, arrow function
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.2.2#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXzDigxAB4AoeK+AZQ2IRAA8TVgBneAJXBxmFLsMMLKgDmAGnhRUATwB8EytQAixKPGasO3Xv0HDRk6XMXKqAQUy5UnLSDacAFEIYAuWvRJTg6j2voASngAXnldMD4BIRFxKRkFJXknWDF2DwBvczEQDDp3eCdgsM8GAG5zKGs8dPgrbBqK6hyMAKgPItDwtoqAX0CPADccLGAK8kIQBics6ngW-JJO2bnqOAxkGHwM6Q8ARnhe80OlOZa2juLwldX4dc3t+AAjDwAmQ+Pe0+oqhtsXLwgHzqYI3VauEjHOYAemh8AAegB+KHUXz0FFUWEI5G3Kj3LbwMG4+AAL32GI+cyO-SAA
💻 Code
🙁 Actual behavior
The getState and getData function types need to be consistent. For example, they are both arrow functions or ordinary functions to correctly infer the type. Otherwise, they cannot
🙂 Expected behavior
No matter what type of functions getState and getData are, the types can be correctly inferred in the actions function parameters.
Additional information about the issue
No response