Let's take a closer look at my code, which lacks proper descriptions.
Here is the interface:
interface IModel<T = any> {
effects: {
[key: string]: (getState: () => T) => void;
};
}
interface IState {
name: string;
age: number;
}
I know this is incorrect, but I'm not sure why:
class Model implements IModel<IState> {
effects = {
getName: (getState) => {
const { /** Here, Ts has no smart tips */ } = getState();
}
};
}
If I add type, I can get suggestions:
class Model implements IModel<IState> {
effects = {
getName: (getState: () => IState) => { // add type
const { /** Yes, have 'name' and 'age' */ } = getState();
}
};
}
However, I find the latter approach a bit too verbose.