-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Add module react-dom #5828
Add module react-dom #5828
Conversation
Obviously this needs to get added one way or another for React v0.14. I had originally thought we'd include it in the normal I think I'm still leaning towards putting everything in a single definition file. I think it would make it much easier for developers to just get up and running, but shrug. What do others think? |
Basicly you totally right that's a mass of definitions for only little packages, I didn't thought about this. I see only one reason for creating a folder for each package: The would be correspond the current structure of the repository: One folder for one npm module. So maybe some developer search for a react-dom folder don't find one and think that there is no definition for react-dom. Maybe they don't think that the definition is already included in the react.d.ts file. |
I'm a fan of one react folder where each of these files exist. Using the principle that of avoiding run time errors, it seems like you should only have access to a module if you explicitly include it. Ex, it would be frustrating for a developer to require react-dom because it is in the typings but then crash because it is not in your node_modules |
also pinging @johnnyreilly since he's a maintainer and has some React experience. |
I like the way in angular 1.x we've nicely separated out each of the definition files so the user can include what they need as they use it. I'd quite like a similar appraoch to be used for React unless there's a compelling reason why not. All that said, I'm still a little on the fence... |
Given there is a precedent, it seems best follow it to maintain consistency On Wed, Sep 16, 2015, 3:31 AM John Reilly [email protected] wrote:
|
So if I understand everyone correctly, @pspeter3 suggested the following approach: DefinitelyTyped/react/react-dom.d.ts (note: not DefinitelyTyped/react-dom/react-dom.d.ts) Angular 1.x also uses the same approach. @johnnyreilly is on the fence but leaning toward the same approach Assuming this is the case, @B-Stefan could you update the PR to put |
As a separate issue, this doesn't address a global version. I think we would also need a react-dom-global.d.ts which exposes whatever the global API is (I don't actually know how they're handling this, I haven't looked. If they're just bundling it with the global React then maybe the existing definitions already work). |
Is there a consistent global version after these changes? I would assume no since you would have to access them through npm anyway. I would prefer not having a global version and ideally but that may not be tenable. |
Bumping since React 0.14.0 was released today, can we get an update on this one? |
I think this one could be merged if the files are moved. I'm working on a more comprehensive v14 typings update. |
Done |
Awesome, thanks @johnnyreilly! 🎈 |
Doh.... but this wasn't ready to be merged :( the files weren't moved yet. |
We also need to add the other modules too. I think React 0.14 type definitions will need more coordination than this. |
OK - feel free to submit another PR and ping me |
I think the boundaries should be at modules, if I have to |
I agree with @alexgorbatchev not everyone need the react-dom module, and if this has to be merged so will have many others. I think many conveniently separated modules serve better maintainability and readability than having one GOD module that has everything. |
I'm wondering if there is some confusion going on here though. Just because However, I just did some testing with tsd (I don't really use tsd regularly) and I was under the impression that My (personal) goal is ease-of-use. I was under the impression that putting everything under the react folder would make things easy since someone could just use |
I didn't know about Having said that, a decision needs to be made whether or not to restrict
|
@jbrantly I did kinda confuse moving react-dom to reach folder with adding react-dom definitions to the |
I'm a little torn. On the one hand I like the idea that you have an equivalent I dunno. DefinitelyTyped is now so full it's becoming hard to navigate. That also tempts me in the single official folder direction... |
Yea, if we did keep everything under the react folder it would be "official" packages only. |
I strongly want a single folder as well. Finding which definitions exist and which do not would be a pain otherwise. |
Code mirror is all in a single folder and I love it https://github.com/borisyankov/DefinitelyTyped/tree/master/codemirror |
👍 for single folder for official Facebook react modules |
Question for proponents of the single folder approach: would you expect |
With the current setup I would expect all typings for official react modules to be in |
Yes, but that doesn't mean all of the irrelevant typings would be used. You would still need to add to tsconfig.json or a tripleslash reference. |
only if they manually download them all. If they |
Holy crap you're right. That's awesome. We can get the best of both worlds. |
Woah....did not know that. Full steam ahead with single folder then! |
Wouldn't it be great if we could convince our Facebook friends to take these files into their repo. Then we wouldn't need tsd at all for React. |
Potentially but it would also make it harder for us to update them. |
@joewood this isn't as far fetched as you might imagine. Facebook are more focused on using Flow (similar to TypeScript but not the same). However, one of the goals of Flow is to have support for Once that happens, then maybe it might become a possibility for FB to ship definition files with React itself. This is not something that is likely to happen anytime soon but you could try asking @spicyj / @zpao if they've any idea whether React is ever likely to ship with it's own definition files? It'd be nice! |
fwiw they already ship definition files for immutablejs https://github.com/facebook/immutable-js/tree/master/type-definitions 🌹 |
Good point @basarat! Ironically I've used immutable js but never actually with TypeScript. 😄 |
👍 for single folder for official Facebook react modules |
Add the react-dom definitions for [email protected],
Definitions copied from react.d.ts