-
Notifications
You must be signed in to change notification settings - Fork 5
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
Update TypeScript declarations to work with Redux 3 & 4 #7
Comments
The main reason to update the TS declaration is that Redux has been rewritten with TypeScript, so the (Off topic, are you interested in doing similar rewrite?) The suggestions from @ankon are excellent. As But for those who use pre-TS redux, if we drop So we need to drop the @types/redux dep, add a redux@4 peer dep, and bump a major version Besides, in TS Redux definition, Dispatch accepts an import { Action } from 'redux'
type Dispatcher<MS, A> = (dispatch: Dispatch<A>, currentState: MS, previousState: MS) => unknown;
// or no reload, just type Dispatcher<MS, A extends Action = AnyAction> = (dispatch: Dispatch<A>, currentState: MS, previousState: MS) => unknown;
export function observer<S, MS, A extends Action>(mapper: Mapper<S, MS>, dispatcher: Dispatcher<MS, A>, options?: Options): Observer<S, MS>; Please correct me in case of any error @ankon |
and also, we need to add some TypeScript type checking to make sure the declaration works with some concrete example |
Thanks a lot for your input, @KagamiChan. I created a pull request with some changes to the TypeScript declarations (#8) and added some comments there. Please take a look, if you have the time. I should mention upfront that I haven't written any TypeScript before today and I haven't used this package (or Redux) in years, so I'm learning as we're going. Regarding Regarding a rewrite: do you mean a rewrite in TypeScript? No, I don't think it's necessary. Getting the declarations to work correctly would be more than enough, in my opinion. Regarding your code suggestions: I did include something similar in #8 (f13a2a4). What do you make of it? |
Thanks for your quick response The type checking I mentioned is write some TS code to consume the package in various way and see if there's no conplaints from Sorry, I forgot that they have shipped with typings before TS rewrite. They should have picked the dts file from definitivelyTyped repo, and I see that currently |
Yes, I'm writing some tests to ensure that the type declarations work with I'll take a look at your comments from #8 a bit later. Thanks! |
For more details, see PR #6.
The text was updated successfully, but these errors were encountered: