4 ms·
I'm not sure if I understand fully this babel <-> typescript integration. Can you help me understand this? What's the point? So in future babel would be able
by mpawelski 9y ago
I'm not sure if I understand fully this babel <-> typescript integration. Can you help me understand this?
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 https://github.com/TypeStrong/ts-loader and https://github.com/s-panferov/awesome-typescript-loader 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 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?
- lhnz 9y agoFor example, the React team provide a set of codemods to help automatically upgrade codebases when there is a new version of React (https://github.com/reactjs/react-codemod https://github.com/reactjs/react-codemod). Until `recast` gets TypeScript support, everybody who uses TypeScript has to do this repetitive work manually. 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/babel-plugin-emotion 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 https://github.com/thejameskyle/babel-react-optimize).