by lhnz · 8y ago · 0 comments
It seems to be faster and there is better integration with `jest`, `rollup`, various css-in-js libraries and (maybe in future?) `create-react-app`. (I still run `tslint` and `typescript` in the background for type-checking and linting. And I've written a tiny CLI to generate flat `index.d.ts` files to share my packages.)
The one thing I still miss about JavaScript is the possibility of writing codemods to speed-up upgrades. Unfortunately, in order for `jscodeshift` to support TypeScript, I think there would need to be some further work on `recast` (https://github.com/benjamn/recast/issues/424).
Hopefully the TypeScript team will continue to work closely with the Babel team, since this would be very good for the eco-system.
What's the point?
So in future babel would be able to parse TS file and output JS file with all the transformations it supports? So it's useful if you want to use some new EsNext feature currently not supported by TS compiler?
Is this the main advantage? Because for me it looks like a pretty weak reason (TS has improved a lot when it comes to supporting new ESNext features). Anyway, from what I understand TS provide API that for example webpack loaders use (like https://github.com/TypeStrong/ts-loader and https://github.com/s-panferov/awesome-typescript-loader) and it looks that those can be integrated with babel.
Or is it mainly to support tools that depends on babel for parsing AST? And microsoft is willing to maintain this babel integration for next versions of TS? So non-microsoft community developed tools can easily add support for TS (instead of only supporting JS), like Prettier did (https://github.com/prettier/prettier/issues/13)?
But are everyone using babel for JS parsing? I'm not that into JS tools community, and am a bit confused by all this ESTree, Esprima, recast, jscodeshift projects and relationship between them. You mentioned `recast` TS support and it looks they want to use babel for this too. So it's microsoft bet that all future JS tools that need to parse JavaScript AST will use babel for that, and hence they will add TypeScript support because it would be easy?
Another example is how many `css-in-js` libraries require Babel plugins to work their best (e.g. https://github.com/emotion-js/emotion/tree/master/packages/b...).
And additionally there are also plugins that optimize React code (e.g. https://github.com/thejameskyle/babel-react-optimize).