4 ms·
Personally I've moved away from the TypeScript compiler and towards the betas of `babel@7` and `@babel/preset-typescript` (https://www.npmjs.com/package/@babel/
by lhnz 9y ago
Personally I've moved away from the TypeScript compiler and towards the betas of `babel@7` and `@babel/preset-typescript` (https://www.npmjs.com/package/@babel/preset-typescript https://www.npmjs.com/package/@babel/preset-typescript).
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 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.
- mpawelski 9y agoI'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).
- ascorbic 9y agoWhat are you missing with Jest in TypeScript? For me, ts-jest is completely seamless.