Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Initial React v0.14 definitions - #6205

#6205
Merged
johnnyreilly merged 23 commits into
DefinitelyTyped:masterDefinitelyTyped/DefinitelyTyped:masterfrom
jbrantly:react-v14jbrantly/DefinitelyTyped:react-v14Copy head branch name to clipboard
Nov 12, 2015
Merged

Initial React v0.14 definitions#6205
johnnyreilly merged 23 commits into
DefinitelyTyped:masterDefinitelyTyped/DefinitelyTyped:masterfrom
jbrantly:react-v14jbrantly/DefinitelyTyped:react-v14Copy head branch name to clipboard

Conversation

@jbrantly

@jbrantly jbrantly commented Oct 8, 2015

Copy link
Copy Markdown
Contributor

This is a WIP PR for React v0.14 definitions. This supercedes and incorporates feedback from #5828

Things done:

  • Created separate definition files for the various new packages like react-dom and react-addons-*
  • Created/updated definitions for react-dom and react-dom/server and removed those from react
    • Moved and renamed batchedUpdates addon to unstable_batchedUpdates
    • Added unstable_renderSubtreeIntoContainer
    • Added version
  • Moved addon definitions to their respective individual files
  • Removed react/addons (yay!!)
  • Removed initializeTouchEvents
  • Removed classSet
  • Removed setProps and replaceProps since they're deprecated
  • Removed getDOMNode since it's deprecated
  • Removed cloneWithProps since it's deprecated
  • Refactored react-global.d.ts to pull in definitions from the various addon definitions files instead of duplicating
  • Added legacy v0.13 files
  • React.Children.toArray - done by @thasner
  • React.Children.map - done by @thasner
  • Update tests
  • Remove react-dom folder based on discussion in Add module react-dom #5828
  • New ref behavior for DOM elements - done by @vsiao
  • Stateless function components - done by @vsiao
  • shallowCompare addon - done by @pspeter3
  • CSSTransitionGroup updates
  • New elements/attributes - done by @vsiao
  • per @drbignik, "valueLink support should also be added to HTMLAttributes to support LinkedStateMixin" - done by @vsiao

I've also not addressed updates to elements/attributes. I plan to make a thorough update to these at a later date. @vsiao did this

Questions:

  • cloneWithProps addon is deprecated. Should we just remove it? removed per discussion
  • I've removed other deprecated items already since TS doesn't really have a way to show that something is deprecated but it's useful to use TS when upgrading. Others might feel differently.
  • Should we make individual test files for each addon definition or keep a monolithic test file like today? I'm thinking monolithic but would like opinions. One thing to keep in mind is Proposal: guidance on modules/globals #6125. seems like we've gone monolithic for now
  • Should we put the existing v0.13 definitions in a legacy folder? added using DT conventions

If anyone wants collab on my fork to help out just ask.

Not sure who all is interested in this so I'm just going to ping everyone who has had passing interest in the past: @pspeter3 @vsiao @basarat @johnnyreilly @RyanCavanaugh @ngbrown @B-Stefan @use-strict

@johnnyreilly

Copy link
Copy Markdown
Member

Re: deprecated, I think remove - it's embracing the inevitable. If people shout we could look at adding back.

I favour breaking up the tests but I don't really mind. Monolithic is fine.

@use-strict

Copy link
Copy Markdown
Contributor

For now, I'm thinking you should move the old v0.13 definitions to a separate legacy folder instead of overwriting them.

I'm also for splitting the tests.

@jbrantly

jbrantly commented Oct 8, 2015

Copy link
Copy Markdown
Contributor Author

For now, I'm thinking you should move the old v0.13 definitions to a separate legacy folder instead of overwriting them.

I actually meant to put that under "Questions". We did that with v0.12, it makes sense to me as well.

I favour breaking up the tests but I don't really mind
I'm also for splitting the tests.

One "gotcha" with the tests is #6125. Essentially if we want to split and also test both the module and the global version, we'd wind up with N modules * 2 which here = 20 test files. If we split should we forego testing the global version? Or should we just suck it up and have 20 test files? Or some other solution that I'm (hopefully) missing.

@use-strict

Copy link
Copy Markdown
Contributor

@jbrantly , in this case it's probably overkill. All addons in a single file (x2) should be fine.

Comment thread react/react-dom.d.ts Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a module instead of a namespace?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right, it should be namespace.

@pspeter3

Copy link
Copy Markdown
Contributor

I think that we should remove the deprecated items as well. @jbrantly, what is the best way to help out?

@jbrantly

Copy link
Copy Markdown
Contributor Author

what is the best way to help out?

I've given you collab access to my fork so you can push to this PR if you want. Feel free to take anything on the list, I haven't had a chance to do anything more yet.

@pspeter3

Copy link
Copy Markdown
Contributor

Thanks!

@jbrantly

Copy link
Copy Markdown
Contributor Author

I just rebased on top of master to pull in #6236. I'm going to start working on some of the various items that were commented on.

@jbrantly

Copy link
Copy Markdown
Contributor Author

I've addressed the various comments in the thread so far:

Plenty of stuff still left to do though.

@johnnyreilly

Copy link
Copy Markdown
Member

Good work!

@use-strict

Copy link
Copy Markdown
Contributor

👍

@vvakame

vvakame commented Oct 16, 2015

Copy link
Copy Markdown
Member

travis ci failed. please merge master into this branch.

@jbrantly

Copy link
Copy Markdown
Contributor Author

@vvakame This is still a WIP and the tests haven't been updated yet 😄 That's why travis is failing. I'll ping when everything is done and ready to be merged.

@pspeter3

Copy link
Copy Markdown
Contributor

I'm curious about how we're going to do stateless function components. They don't seem like they would have an obvious type signature except for <T extends React.Props<any>>(props: T) => React.ReactElement<any>. Do people agree?

@dallonf

dallonf commented Oct 17, 2015

Copy link
Copy Markdown

@pspeter3 According to this ticket, it doesn't look like function components are going to be supported by TypeScript yet: microsoft/TypeScript#4861

@jbrantly

Copy link
Copy Markdown
Contributor Author

@dallonf Thanks for that link. I've been meaning to open that issue for the longest time but never got around to it. I'm glad to see someone else already did it.

@pspeter3 That seems right to me. I think the main thing will be updating createElement to accept them as component types.

@RyanCavanaugh

Copy link
Copy Markdown
Member

@dallonf FWIW I intend to address microsoft/TypeScript#4861 this week

@jbrantly

Copy link
Copy Markdown
Contributor Author

@RyanCavanaugh that is excellent news! Looking forward to it.

@NikitaKurpas

Copy link
Copy Markdown

valueLink support should also be added to HTMLAttributes to support LinkedStateMixin.

@vsiao

vsiao commented Nov 11, 2015

Copy link
Copy Markdown
Contributor

@jbrantly looks like we're done with the remaining tasks except for CSSTransitionGroup updates and testing. I've already been adding tests as I go. Do you know what still needs to be tested?

@jbrantly

Copy link
Copy Markdown
Contributor Author

@vsiao Awesome! I just finished up the CSSTransitionGroup update and also fixing dependency tests. My "Test, test, test" comment was more about upgrading real-world applications and not so much the unit tests, but I'm not sure if that's practical. I've removed that item.

There is only one remaining item I think related to the valueLink changes and the material-ui definitions (see my comment on 813f3b0).

@vsiao

vsiao commented Nov 12, 2015

Copy link
Copy Markdown
Contributor

Done! Passing tests finally 😄

@jbrantly jbrantly changed the title WIP: Initial React v0.14 definitions Initial React v0.14 definitions Nov 12, 2015
@jbrantly

Copy link
Copy Markdown
Contributor Author

OK! I think everything is done and ready to be merged!

@vvakame

johnnyreilly added a commit that referenced this pull request Nov 12, 2015
Initial React v0.14 definitions
@johnnyreilly
johnnyreilly merged commit c2c22c3 into DefinitelyTyped:master Nov 12, 2015
@johnnyreilly

Copy link
Copy Markdown
Member

Merged - well done!

@pspeter3

Copy link
Copy Markdown
Contributor

Thanks for driving this @jbrantly

@myitcv

myitcv commented Nov 12, 2015

Copy link
Copy Markdown
Contributor

Thanks to everyone involved. Very much appreciated.

@jbrantly

Copy link
Copy Markdown
Contributor Author

Yup, thanks to everyone who contributed with code or comments!

@jfahrenkrug

Copy link
Copy Markdown
Contributor

Thank all of you so much for all your hard work on this!

@adidahiya

Copy link
Copy Markdown
Contributor

thanks all 🌟 will start testing these definitions soon!

@alexgorbatchev

Copy link
Copy Markdown
Contributor

Amazing work, thank you so much everyone!

@vsiao
vsiao deleted the react-v14 branch November 12, 2015 20:05
@rhysd

rhysd commented Nov 13, 2015

Copy link
Copy Markdown
Contributor

Thank you for the great work!

@pserwylo

Copy link
Copy Markdown

Thanks all for your hard work on this. We've been using these while they have been in progress, and so far no problems at all.

@twhitbeck

Copy link
Copy Markdown
Contributor

I have an issue using ES6 module syntax in TypeScript/Visual Studio 2013.

import * as update from 'react-addons-update';

error: "Module react-addons-update resolves to a non-module entity and cannot be imported using this construct"

import update = require('react-addons-update');

No error. Do I have to use this syntax? I'm using es6 syntax everywhere else. :(

@use-strict

Copy link
Copy Markdown
Contributor

tl;dr: you have to use import ... = require(...) in this case.

import ... from ... is used for importing ES6 modules. import * as ... usually works with most commonjs because it translates to using the exports object. However, there is no equivalent to module.exports = construct in the ES6 spec. Even the default export ends up as an export.default = ... and you cannot override the exports object.

@Strate

Strate commented Nov 24, 2015

Copy link
Copy Markdown
Contributor

type ReactInstance = Component<any, any> | Element is wrong. Trying to accessing any Element's property gives me a compilation error:

this.refs['refname'].scrollHeight // error TS2339: Property 'scrollHeight' does not exist on type 'Component<any, any> | Element'.

This happening because of typescript union type spec:

The type A|B has a property P of type X|Y if A has a property P of type X and B has a property P of type Y.
(from Properties section)

Instead of using union type, there should be intersection type, which completely fits to this case:

The type A & B has a property P if A has a property P or B has a property P.
(from Properties section)

So, there should be type ReactInstance = Component<any, any> & Element

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.