New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
typings: make lettable ofType properly narrow action type #385
Conversation
index.d.ts
Outdated
@@ -52,6 +52,6 @@ export declare function createEpicMiddleware<T extends Action, S, D = any>(rootE | |||
export declare function combineEpics<T extends Action, S, D = any>(...epics: Epic<T, S, D>[]): Epic<T, S, D>; | |||
export declare function combineEpics<E>(...epics: E[]): E; | |||
|
|||
export declare function ofType<T extends Action>(...keys: T['type'][]): (source: Observable<T>) => Observable<T>; | |||
export declare function ofType<T extends Action, R extends T, K extends R['type'] = R['type']>(...key: K[]): (source: Observable<T>) => Observable<R>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this would be a breaking change since it now requires two params instead of one. But if we provide a default param for the second one I think that would make it non-breaking and have the same behavior as before wouldn't it? R extends T = T
ofType<T extends Action, R extends T = T, K extends R['type'] = R['type']>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, good catch! my bad thx!
Thank you for this! Let's discuss my breaking change comment a bit. Also, I kicked the build as it failed for unrelated reasons and should pass now, assuming it would otherwise. |
- docs: add typescript ofType troubleshooting solution - chore(npm-scripts): enable all strict type-checking options for TS tests - test(typings): cover ofType proper type narrowing - docs: fix code typos - fix(typings): make ofType definition non breaking Closes redux-observable#382
hey @jayphelps sorry it took so long :( too busy lately
thx! |
Thanks again! |
|
I have read the Contributor Guide
My commit messages are in conventional-changelog-standard format.
adds Typescript docs to troubleshooting
enables strict mode for TS test
covers proper type narrowing within TS tests
Closes #382