Hacker News new | ask | show | jobs
by solidr53 2804 days ago
Pretty much just file extension support and docs. The support mainly comes from Babel 7.
3 comments

I'd call that a good thing, really. Not needing ever more dependencies.

I think this is a solid direction to go.

Let's just say I give the React devs... props.

Funny, cause just using typescript to compile means you get to drop a lot of Babel dependencies / eslint dependencies.
There's still react-scripts-ts [1] which drops the majority of Babel in the CRA pipeline for solely Typescript. Presumably, it will remain active as it is still a useful alternative if you know you are going to want Typescript from day one. (This Babel-based support is perfect for those unsure and looking to experiment, which is great.)

[1] https://github.com/wmonk/create-react-app-typescript

I use react-scripts-ts. There's an open issue discussing the future of it now that CRA does it on its own.

https://github.com/wmonk/create-react-app-typescript/issues/...

create-react-app is built on Webpack, for hot module replacement (HMR), and that requires a webpack loader. There's babel-loader and ts-loader. The stats in the projects are similar, but babel-loader is part of the babel project while ts-loader comes from an independent project, so it may be better integrated. Also ts-loader suggests using it with babel-loader. I'm not sure why, but if you install ts-loader and babel-loader you'll wind up with more dependencies than if you just install babel-loader. https://github.com/babel/babel-loader https://github.com/TypeStrong/ts-loader
The last I checked (a month or so ago, but before the recent 2.0 release) create-react-app didn’t have hit module replacement. It just watched files and completely reloaded the browser when anything changed.
How well does Babel transpile TS? My initial instinct is that I'd trust the real TS compiler over Babel, but I've never tried compiling TS with Babel.

I assume the real TypeScript compiler still does the type-checking and that would be unaffected by Babel.

The TS team implemented the TS parsing support in Babel. You are correct that the TS compiler is still needed for the typechecker, however.
Ah, I didn't realize this, very cool collaboration! For those who are reading this and might find it helpful, here's a link to the official blog post on the work: https://blogs.msdn.microsoft.com/typescript/2018/08/27/types...
We added more changes on master, now it creates tsconfig automatically, checks if the required dependencies are installed and other nice ux improvements.