You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project offers a way to ensure typing between Components and Models. But we still have typing issues within Models since yield ends up with an any return type, as is explained under microsoft/TypeScript#2983. E.g. in redux-saga Models we often have cases like:
constresult=yieldthis.effects.call(fn,payload);// <- result is any
Models plays an important role in firing API calls and gathering API responses. And since that's error-prone for data typing, it would be very helpful to make those effect calls type sensitive.
For example, we may wrap effects.call into another generator with type declaration, so that we have:
In lib/BaseModel.d.ts,
typeFunctionType=(()=>any)|((...args: any)=>any);typeUnpromise<TextendsFunctionType>=ReturnType<T>extendsPromise<infer U> ? U : ReturnType<T>;// TODO: T may extend GeneratorexportinterfaceEffectsCommandMap<StoreState>extendsDvaEffectsCommandMap{// ...call<FextendsFunctionType>(func: F, ...args: any): Generator<Unpromise<F>,Unpromise<F>>,// ...}
This project offers a way to ensure typing between Components and Models. But we still have typing issues within Models since
yield
ends up with anany
return type, as is explained under microsoft/TypeScript#2983. E.g. in redux-saga Models we often have cases like:Models plays an important role in firing API calls and gathering API responses. And since that's error-prone for data typing, it would be very helpful to make those effect calls type sensitive.
For example, we may wrap
effects.call
into another generator with type declaration, so that we have:In
lib/BaseModel.d.ts
,In
src/decorators/effect.ts
,And in model files, by replacing
yield
withyield*
,Will such a patch make sense to this project?
The text was updated successfully, but these errors were encountered: