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.exportinterfaceReducers<M>{[doSomething: string]:
|(<Pextendsnever>(state: Readonly<M>,action: P)=>M)|(<PextendsAbstractAction>(state: Readonly<M>,action: P)=>M);}exportdefaultfunctioncreateModel<M,RextendsReducers<M>,EextendsEffects>(model: {namespace: string;state: M;reducers: R;effects?: E;}){
...
}constmodel=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: