4 ms·
Sorry but what is the use case for Babel + TS? I thought you use either Babel or TS but not both together.
by octref 9y ago
Sorry but what is the use case for Babel + TS? I thought you use either Babel or TS but not both together.
- pygy_ 9y agoBabel can now parse TypeScript source and turn it into an AST. It doesn't check types at this point.
- a_humean 9y agoYou can use Babel with TS. For example, for JSX you can tell TS to "preserve" the JSX, which means you can tell babel or some other compiler take care of that transformation[1]. You can also use babel with typescript to use the babel presets for stage-[0-4] plugins. You can use the webpack TS loader, awesome-typescript-loader, to work with babel[2]. [1] https://www.typescriptlang.org/docs/handbook/jsx.html https://www.typescriptlang.org/docs/handbook/jsx.html [2] https://github.com/s-panferov/awesome-typescript-loader https://github.com/s-panferov/awesome-typescript-loader
- mercer 9y agoOne case I ran into: using css-loader/style-loader for my css. TS doesn't understand importing css files, so that's where Babel comes in. In the end i decided to stick to 'old-fashioned' SCSS with an npm script; the downsides of adding Babel to my stack weren't worth the upsides of css modules. Difficult decision to make though. I guess what I'm saying is that while there is a use case, so far it's been worth it to just stick to TS without Babel, much as I wish it'd be different.
- ksjogo 9y agoYou could use the webpack (which you might be using already) css loader and declare the css file as any.