Live data from Hacker News

If TypeScript is so great, how come all notable ReactJS projects use Babel?

discuss.reactjs.org

201–210 of 247 posts

Re: If TypeScript is so great, how come all notable ReactJS projects use Babel?

#201
post #91

TypeScript works very well with React, less so with Redux/ImmutableJS. We just moved our app from Redux and ImmutableJS to mobx and it's been a treat: we now get full typing and it's much less verbose. We don't need to repeat the payload definition at every point, we have a store where we call a method and that's it. Highly recommend checking out mobx if you use TS.

I've been using Typescript, React, and mobx and absolutely in love with how they all work together. For me the high-level summary is that the vast majority of my logic is moved out of React views and into stores / controllers / whatever, with almost no boilerplate to make them play nicely together. The way its coming along reminds me of Ember quite a bit, but I get to use React and POJO's.

I definitely want to look into mobx now. Just thought I would throw out there that I've been using Nuclear-js/Immutable.js and it has a lot of the benefits you mentioned. All the data manipulation logic is encapsulated nicely, and merely appears as state to your components. You can observe memoized transforms in your components so that they only need to listen for the data they need, rather than a single change event on an entire store.

Re: If TypeScript is so great, how come all notable ReactJS projects use Babel?

#202

Why not both? I just installed flow and checked the JavaScript output of my TypeScript project (~2000 lines) and was a little disappointed it didn't turn up any errors.

Flow only type-checks files that have opted into it with the //@flow comment. It will have some trouble dealing with the compiled output of another tool like Typescript. For example, it probably wouldn't understand that output of how Typescript compiles classes into ES5 represents a class.

Even if using both of them on the same code worked, Flow and Typescript are both a bit anal about certain dynamic javascript patterns, and I think any possible extra gains from having both check your code would be canceled out by having to write your code in ways to please both type-systems.

Re: If TypeScript is so great, how come all notable ReactJS projects use Babel?

#203
post #153

I am using TypeScript in a middle sized app (around 200 react components) and its help is invaluable for collaborating and sharing APIs. Currently it is based on redux, but I have a feeling I have to write too much code, I am looking into MobX as an alternative. I think TypeScript is the best thing that happened to the JS community in a long time.

I just did that (redux -> mobx) as mentioned in another comment and it made the code easier to understand, everything typed with less than half of the code. No more connect or action, we just call the store method (equivalent to a reducer fn) directly.

I also moved most of the components that had state to use observable variables and it's been working well.

Re: If TypeScript is so great, how come all notable ReactJS projects use Babel?

#204
post #32

Earlier quoted context omitted.

Is that correct? WASM has no DOM access? (I'm asking, not advocating anything.) How does code that runs in a browser do UI I/O without DOM access? Is the intent that you go on writing all of your I/O and DOM-manipulating code with JavaScript and call WASM-implemented helper functions from JS code?

No DOM access for the MVP. They do plan on eventually supporting it though: https://github.com/WebAssembly/design/blob/master/FutureFeat...

I think we can hack a reverse js proxy before it gets native DOM access.

Re: If TypeScript is so great, how come all notable ReactJS projects use Babel?

#205
post #30

I do not believe compilation nor a type system belong in JavaScript. It's better to have something like "Flow" that does static analysis of the code as you write. I might even go as far as putting on a "tin foil hat" and state that Typescript is a trick to lock you into their proprietary ecosystem of expensive tools that everyone have to buy into just to communicate with you once you are locked in.

> I might even go as far as putting on a "tin foil hat" and state that Typescript is a trick to lock you into their proprietary ecosystem of expensive tools that everyone have to buy into just to communicate with you once you are locked in.

https://github.com/Microsoft/TypeScript is uh... right there. Check the license. Visual Studio code runs Textmate snippets and has a very sublime-like extension system.

There is no vendor lock in.

Re: If TypeScript is so great, how come all notable ReactJS projects use Babel?

#206
post #5

Earlier quoted context omitted.

webassembly can't come soon enough. as a developer who doesn't deal with browser frontends what i read in this thread is madness. (3 comments at the time of writing this...)

WASM doesn't have DOM access or GC. It's not the answer.

In the first release it wont have DOM access or GC

Re: If TypeScript is so great, how come all notable ReactJS projects use Babel?

#207

Isn't a large part of the win for typescript the tooling? Specifically the auto completion and documentation that pops up in various typescript enabled editors. Does such a thing exist for Flow? Could it? If it did that would go a lot further to push me to flow than that it just catches more errors. I get huge productivity gains from my editor helping me with API completions etc...

There are many code analysis engines for JavaScript that can be used as a plugin for code completion. One commonly available as a plugin to many extensible editors is TernJS[0].

[0]: http://ternjs.net/

Re: If TypeScript is so great, how come all notable ReactJS projects use Babel?

#208

I'm not sure if this not a sophisticated trolling :) Imagine the question with random technologies: If ___________ is so great, how come all notable ________ projects use __________? Classic troll magnet :)

If Apache Spark is so great, how come do all notable JS projects use jQuery?

Re: If TypeScript is so great, how come all notable ReactJS projects use Babel?

#209
post #122

Earlier quoted context omitted.

Functional programming is quite old and I wouldn't call it a trend. I'd say it's more like an industry getting better at its craft, similar to the transition toward strong typing.

We finally have tolerable garbage collectors.

And languages like Rust, which are working toward eliminating the need for a garbage collector.

Re: If TypeScript is so great, how come all notable ReactJS projects use Babel?

#210

Earlier quoted context omitted.

> It would only increase the concept count in an educational setting where you want to only show the thing you're trying to explain. As someone who has written a long tutorial, this makes total sense. When I was first looking at the react ecosystem, it was very frustrating because of the high cost of picking pieces to work together. I really liked http://teropa.info/blog/2015/09/10/full-stack-redux-tutorial... becaus…

This is basically my frustration with the whole trend toward smaller pieces over big monoliths. I don't need a best-in-class every tiny little thing; I just want reasonable tools I can expect to work together well.

This was exactly my thought and I was so glad when I saw this talk[1] address it.

On a side note, I had submitted this to HN but somehow my submissions are visible only to me and doesn't appear when I checked the newest tab after logging out.

[1]: https://youtu.be/OcUzuQ_31co?t=34m5s (the relevant part in the EmberCamp keynote by Yehuda Katz and Tom Dale)

Post reply on HN