Live data from Hacker News

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

discuss.reactjs.org

211–220 of 247 posts

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

#211
post #20

Earlier quoted context omitted.

Immutable.js ( https://facebook.github.io/immutable-js/ ) doesn't have the greatest typescript type annotations. Due to limitations of TypeScript, there is no way to write types for immutable.js heterogenous maps (homogenous Maps and Vectors are fine though). Since immutable.js collections are recommended to be used with redux, and no one wants to bother using IMJS records instead of just maps, the types end up being…

I feel like TypeScript needs some work in areas around typing methods - for example, I ran into type issues when trying to go more functional via ramda.js ( http://ramdajs.com/ ) using stuff like compose, and ultimately it felt like a limitation of TypeScript.

To properly type Ramda, you need higher kinded types, which are not yet a feature of TypeScript.

Though I find that Ramda's curried style isn't that useful now that we have arrow functions...

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

#212
post #190

Earlier quoted context omitted.

Under what mechanism would the "extinguish" part be at all possible?

When using TypeScript subtly forces you into a MS toolchain. Then when everyone's hooked on VS Code BAM VS Code Pro Extreme Edition!

Considering VS Code is a light, free alternative to Visual Studio, that scenario is positively absurd.

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

#213
post #190

Earlier quoted context omitted.

Under what mechanism would the "extinguish" part be at all possible?

When using TypeScript subtly forces you into a MS toolchain. Then when everyone's hooked on VS Code BAM VS Code Pro Extreme Edition!

Strangely enough, I'd feel this would be fine. I would pay for a non-free upgrade of VSCode if it really brings in enough value. Its already on par with Sublime, and I paid for that...

edit: Though if you mean TypeScript depending on VSCode to build, I doubt thats even possible at this point. Everything is available via the command line. Heck, there are even tools that build on top of the compiler API. (dts-generator, tslint etc)

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

#214
post #171

Earlier quoted context omitted.

Sorry for the confusing comment -- I updated it. I was saying that it is strange for the linked post to talk about soundness being important when it's trivial to find an unsound Flow program. (This particular program is properly rejected by TypeScript but TypeScript is also unsound so there are plenty of other invalid programs that it accepts.)

I think it's a lot harder to get past TypeScript's type checker. It's probably possible, but I can't think of a way to do it off the top of my head without casting to any. It's a lot easier to show correctly executing javascript programs that would be rejected by the type checker.

Here's one that TypeScript gets wrong. It's kind of a canonical example of a program that is difficult to get right in a type system. (It's how I found the Flow example linked upthread.)

    let x: number[] = [];
    let y: Object[] = x;
    y.push('a');
    let bad = x.pop();
    // bad has type number but is actually a string.

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

#215

Earlier quoted context omitted.

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.

The JS build system ecosystem could definitely use some help along the whole "reasonable tools I can expect to work together well" front. I swear, 30% of my time is spent fighting the build systems and their plugins that hate each other. EDIT: to add, I think the TS team has done such a bangup job on Typescript that I would love it if they could create a build system as well. Some things that would be nice to have: *…

I find webpack to be quite a 'holistic' solution I got pretty much everything out of the box or with minimal googling.

I agree though over-fragmentation is a huge problem for JS, we need the big players (either foundations or companies) to put their weight behind one or two solutions and just get on with it :-)

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

#216
post #43

Please don't bury this comment completely. I am going to be honest and tell you that I believe TypeScript is pure embrace, extend, extinguish from Microsoft. And I am amazed honestly that so many web developers are eating it up.

Let's say that tomorrow, Microsoft releases a totally-backwards-incompatible build of Typescript, and starts charging for it. My "way out" of the Typescript ecosystem is: 1.) Change the target to "ES6", and run a compile. 2.) Take those files and use them as my new source files. 3.) Remove Typescript from my build pipeline. Done. Easiest language migration I've ever done.

Its interesting that on one hand, we have this shouting "embrace, extend, extinguish!" directed at TypeScript, and on the other, Facebook with Flow and Babel is doing precisely that: its extending JS with their own type system, adding support for said type annotations to Babel (which is still thought of as the es.next -> es.current compiler) and still calling it JavaScript; or at least, muddying the waters (no extension change).

Strangely, it appears to work. I've seen claims that Flow is better because "its just JavaScript, not another language"

I don't get it.

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

#218
post #186

Earlier quoted context omitted.

Flow understands some TC39 proposals, if you use the right flags: esproposal.class_instance_fields=enable but it chokes on ones it doesn't understand. I tried using Flow and RxJS in the same codebase. RxJS makes heavy use of the pipeline operator: stream::map(thing) vs map.call(stream, thing) Flow will stop checking types as soon as it sees ::. Babel parses it, but Flow runs in parallel, so it needs to be able to wal…

The pipeline operating is super speculative. I would suggest not using it yet.

It's still early, but it makes Rx code much easier to read. So long as you're comfortable using Babel for transpilation, it doesn't really matter whether or not it's TC39-approved.

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

#219
post #67
post #26

Earlier quoted context omitted.

it's like they don't even realize how ridiculous this shit sounds..

I don't think the point of WebAssembly is to target the DOM. I think it it's to provide a common low level API across browsers that many languages can target.

WASM is supposed to be first class citizen so I don't see any reason why it shouldn't have access to the DOM or any other browser feature available to JS.

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

#220

Speaking as the person who implemented JSX support for TypeScript, I question the premise! JSX support (and implementation of React semantics for typechecking that JSX) was a very popular feature request. I can tell you just from how quickly people notice when something JSX-related changes in the nightly build that there are a lot of people using TypeScript with React. Also, since this seem to be a popular misconcept…

Thanks for implementing this! I was a bit standoffish at first but after several attempts to implement my own typed-templates[1], I found JSX to be very nice to work with because type safety in templates is hard to come by.

If anyone is interested, I have a working boiler plate with React Server rendering using TypeScript[2].

[1]: https://github.com/styfle/typed-tmpl [2]: https://github.com/styfle/react-server-example-tsx

Post reply on HN