Skip to content
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

Release/maintain TypeScript bindings (.d.ts) for ReactJS #2029

Closed
DanTup opened this issue Aug 12, 2014 · 16 comments
Closed

Release/maintain TypeScript bindings (.d.ts) for ReactJS #2029

DanTup opened this issue Aug 12, 2014 · 16 comments
Assignees

Comments

@DanTup
Copy link

DanTup commented Aug 12, 2014

I really like React; but I kinda hate JavaScript due to lack of typing. TypeScript looks good; but the 3rd party bindings are truly terrible (constantly breaking, and generally not versioned at all well).

The immutable JS collections released recently by Facebook include TypeScript bindings; which fills us with hope that maybe the same might happen for React. Please, make it so :)

I'm aware JSX won't work with TypeScript; that's no big loss; I prefer pure script, it plays nicer with existing JS tools.

@Wolfwyrd
Copy link

+1

1 similar comment
@ronag
Copy link

ronag commented Aug 12, 2014

+1

@syranide
Copy link
Contributor

Related #759

It's very much possible and technically shouldn't be that hard. However, from the discussions so far the devs most likely don't want to officially maintain JSX for any non-JS language out there. I don't think they should either, it's arbitrary and better left for the community, in the case of TS there are syntax conflicts that need to be solved/worked around.

If there's a robust solution that covers the vast majority of languages at the same time it would perhaps make sense, but perhaps an unlikely reality.

@DanTup
Copy link
Author

DanTup commented Aug 12, 2014

I think you've misunderstood; and I don't think #759 is related. That's asking for some support for TypeScript constructs in JSX, which indeed will be complicated.

I'm not asking for any changes to any code/functionality; only for a TypeScript definition file to be released with React. This is not related to JSX at all; it would just annotate the types so TypeScrip can give code-completion and "type checking" for things like react.DOM.xxx and the methods available in each object.

Facebook have already done this with immutable collections; the TypeScript definition is here:
https://github.com/facebook/immutable-js/blob/master/type-definitions/Immutable.d.ts

@DanTup DanTup changed the title Release/maintain TypeScript bindings for ReactJS Release/maintain TypeScript bindings (.d.ts) for ReactJS Aug 12, 2014
@DanTup
Copy link
Author

DanTup commented Aug 12, 2014

FWIW, I believe the bindings could be auto-generated if there's sufficient metadata about the types in react. If the docs are auto-generated, then it's possible just a variation of that script; which would then only need running with each release/checkin to keep current?

@syranide
Copy link
Contributor

Oh ofc. Although it may not be the entire story, it seems that the next release (0.12) will not feature React.createClass as a requirement, but you will provide the class to a function similar to React.createDescriptorFactory instead. That and there's a lot of work being done to make React statically analyzable which I imagine will go some way to improving this some more, but I believe React.createClass is the by far biggest issue with TS today?

@DanTup
Copy link
Author

DanTup commented Aug 12, 2014

I haven't actually tried using TS yet; so I wasn't sure if there were any issues in doing so. I've been bitten recently by poor TS bindings for other projects (like Angular), so since we're prototyping in React, I was trying to raise support for official bindings here in the hope they could be provided (and versioned with React).

To be honest; if we choose to use React, we probably wouldn't be against creating/maintaining bindings ourselves; as long as the required data is exposed in some parsable form (though if it is; it'd be nicer for everyone if FB created them ;-))

@abergs
Copy link

abergs commented Aug 14, 2014

Hey there @DanTup.

Typescript is currently not very compatible with React, and it seems the problem needs fixing on both sides of the fence. You could have a look at this project https://github.com/fdecampredon/react-typescript by @fdecampredon. My comment in #759 should also be of interest to you: #759 (comment)

I love typescript but I also like to think in Components like React allows you to. The way we are currently progressing is that we are building all views and components in JSX and all stores / logic in TS until we can go full Typescript (which i hope is something like 6-12 months away)

@DanTup
Copy link
Author

DanTup commented Aug 14, 2014

@abergs Thanks for the info; I'd read through #759, but it seemed to be much bigger than I was asking for (JSX support is certainly complicated, and we're not all that interested in that due to poor tooling support). I hoped it'd be possible to have TS support just for code-completion and type checking in components (ideally with generics so our State/Props could be typed too).

It's not a dealbreaker; since as you point out, we could still use TS for the rest of the code; it'd just be nice if we got the benefits of TS everywhere :-)

@abergs
Copy link

abergs commented Aug 14, 2014

@DanTup I'm with you!

However the issues linked in my #759 (comment) is very much related to react/TS without JSX

@BabakMN
Copy link

BabakMN commented Mar 31, 2015

+1

@vsiao
Copy link
Contributor

vsiao commented Mar 31, 2015

https://github.com/borisyankov/DefinitelyTyped/tree/master/react has up-to-date (unofficial) d.ts files for React. Let me know if you have any issues with them (file an issue over at DefinitelyTyped, cc @vsiao).

@gaearon
Copy link
Collaborator

gaearon commented Oct 27, 2016

Seems like this is resolved.

@gaearon gaearon closed this as completed Oct 27, 2016
@donaldpipowitch
Copy link

@gaearon I wouldn't say it is solved, if you mean the unofficial typings in DefinitelyTyped with that. IMHO these are a workaround. For example it is very hard to control typings for prereleases of React with DefinitelyTyped.

@gaearon
Copy link
Collaborator

gaearon commented Oct 28, 2016

What is actionable for the team here?

@donaldpipowitch
Copy link

I guess we need a statement if the team is interested in including Typescript definitions or not and if they would accept definitions inside a PR what the requirements are.

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

No branches or pull requests

10 participants