Live data from Hacker News

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

discuss.reactjs.org

1–10 of 247 posts

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

#2
From personal experience, you probably want Babel anyway even with TS to deal with some weird edge cases.

I think this has been fixed now. But a couple of weeks ago, I had a case where TS compiler output has to be ES6 (since the code base were using something like constructor.name which isn't in ES5), but then Jest (the test framework) doesn't like ES6 syntax, so Babel is needed to compile whatever Jest didn't like down to just ES5 syntax.

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

#5
post #2

From personal experience, you probably want Babel anyway even with TS to deal with some weird edge cases. I think this has been fixed now. But a couple of weeks ago, I had a case where TS compiler output has to be ES6 (since the code base were using something like constructor.name which isn't in ES5), but then Jest (the test framework) doesn't like ES6 syntax, so Babel is needed to compile whatever Jest didn't like d…

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...)

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

#6
post #2

From personal experience, you probably want Babel anyway even with TS to deal with some weird edge cases. I think this has been fixed now. But a couple of weeks ago, I had a case where TS compiler output has to be ES6 (since the code base were using something like constructor.name which isn't in ES5), but then Jest (the test framework) doesn't like ES6 syntax, so Babel is needed to compile whatever Jest didn't like d…

lol

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

#7
Because a lot of notable ReactJS projects are irritatingly enamored with all the latest ES6/ES7/ESCloudCuckooLand features, not all of which are supported by TypeScript.

I've noticed this a lot in the Redux realm. For every possible problem there seems to be a solution that harnesses one particular new/proposed bell & whistle.

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

#8
TypeScript is a PITA when working with typed immutable records, I don't think there will be a happy solution to that. React stack encourages stuff like immutable.js. In general TS React feels bolted on rather than designed with TS in mind like Angular 2.

I love TS and using ng2 at work. If I was using React I would probably also skip on TS.

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

#10
post #7

Because a lot of notable ReactJS projects are irritatingly enamored with all the latest ES6/ES7/ESCloudCuckooLand features, not all of which are supported by TypeScript. I've noticed this a lot in the Redux realm. For every possible problem there seems to be a solution that harnesses one particular new/proposed bell & whistle.

This.

Many React projects use JSX, decorators and class properties to the max, so they needed babel in the first place.

Now if you want to add types, Flow is easier to integrate than switching to another compiler.

Post reply on HN