-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed as not planned
Closed as not planned
Copy link
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
π 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
π» Code
declare function create<
State extends Record<string, any>,
Data extends Record<string, any>,
Actions extends (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
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created