TypeScript Version: 3.6.3+
Search Terms:
Code
(https://github.com/gogoyqj/tkit/blob/master/packages/model/__tests__/createModelSamples/testPutCallInModelOK.ts)
createModel
[model example]
// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.
export interface Reducers<M> {
[doSomething: string]:
| (<P extends never>(state: Readonly<M>, action: P) => M)
| (<P extends AbstractAction>(state: Readonly<M>, action: P) => M);
}
export default function createModel<M, R extends Reducers<M>, E extends Effects>(model: {
namespace: string;
state: M;
reducers: R;
effects?: E;
}) {
...
}
const model = createModel({
namespace: 'model',
state: modelWithEffectsState,
reducers: {
doSomething: (state, action: { id: number }) => ({ ...state })
},
effects: {
}
});
const { actions } = model;
actions.doSomething({ id: 1 });
Expected behavior:
from 3.3.+ to 3.5.,
while invoking createModel, the pass-in object's properties state's type determines reducers['doSomething'] first argument's type and its type is the type of modelWithEffectsState,
and reducers['doSomething'] second argument's type is the type of model.actions.doSomething's argument type - really wonderful features by generic and type inference
Actual behavior:
while since 3.6.3 reducers['doSomething'] first argument's type becomes any,
is there any way to recover these features, or changes i can make to make createModel works again?
help needed
Playground Link:
Related Issues:
TypeScript Version: 3.6.3+
Search Terms:
Code
(https://github.com/gogoyqj/tkit/blob/master/packages/model/__tests__/createModelSamples/testPutCallInModelOK.ts)
createModel
[model example]
Expected behavior:
from 3.3.+ to 3.5.,
while invoking
createModel, the pass-in object's propertiesstate's type determinesreducers['doSomething']first argument's type and its type is the type ofmodelWithEffectsState,and
reducers['doSomething']second argument's type is the type ofmodel.actions.doSomething's argument type - really wonderful features by generic and type inferenceActual behavior:
while since 3.6.3
reducers['doSomething']first argument's type becomesany,is there any way to recover these features, or changes i can make to make
createModelworks again?help needed
Playground Link:
Related Issues: