I was playing around trying to make a function that creates a store, and tried something like this signature:
function makeStore<T, A extends { [key: string]: (this: T) => void }>(args: {
state: () => T;
actions: A;
}) {}
makeStore({
// state: ()=>({a: 10}),
state() {
return { a: 0 };
},
actions: {
hi() {
this.a;
},
},
});
The this is correctly inferred when I use the arrow function for the state atribute, but not when I use the method style. Why is that?