-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add Typescript definitions. #433
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
Conversation
Any chance we can get testing for these, like we do on Redux? https://github.com/reactjs/redux/blob/master/test/typescript.spec.js |
This typings provided doesn't fit to be bundled with package because the are global. You must convert it to be external module definitions (using import, export keywords, not using global namespace imports, etc) |
|
@timdorr Do the Typescript definitions have to take into account that the library can be used as an UMD module? Also, can I make use of the Typescript 2.0 features for the definitions? @bbenezech I don't see what's missing. Could you explain more in depth? |
@DaanDeMeyer Sorry, disregard. Really sorry. Still trying to wrap my head with TS |
Since I'm not using react-redux anymore I'm not going to be able to implement testing or maintain definitions for the project so I'm closing the pull request. |
@codeandcats suggested I fork and re-request these additions. Before I start, I wonder what are the tasks that need to be performed? I don't mind opening a PR but I'd rather not just copy the code without adding anything myself, unless we are content with the state of this PR before it was closed.
|
@timdorr _bump_ Also, imho it would be fine to target TypeScript 2 since it's backwards compatible with 1.x code so there's really no reason consumers shouldn't be using it now. |
Since MS is pushing the whole @types namespacing on npm, I don't think we need to add them here. They exist on DT and that should be good enough. |
@timdorr |
It's more that our current set of maintainers don't use TS, so we don't have any ability to maintain those typings. If you want to see it here, I'm more than happy to accept a PR, but understand that we'll rely on the community to guide those typings. That's how we did the TS and Flow typings on Redux. I can basically just read through comments and mash the appropriate button. I'm a typing dunce 😄 |
It is not true. @types repos is a fallback for libs that doesn't maintain typings in house. It also introduces compatibility issues.
But again it is much more convinient for consumer to use lib with typings included:
|
I think the optimal situation is to have Flow/TS typings collocated with the code, but have at least 1 project maintainer committed to keeping them updated in step with code changes. |
Ok, let's try. Go easy on me #538 |
Having Typescript definitions in the repository itself saves users from having to download the definitions separately and changes to the main redux definitions can be more easily applied to the react-redux definitions.
I've taken the definitions from the DefinitelyTyped repository. The only change I made is the addition of the generic State type to the connect function so the State parameter of the mapStateToProps function can actually be typed instead of being of the 'any' type.
The rest of the definitions seem to be correct.