TypeScript compilation is one of the great features in Babel 7. Since Babel 7 support was merged to Meteor 1.6 branch, will it be possible to use TypeScript with ecmascript package in Meteor 1.6?
I know currently we have barbatus:typescript to compile TS in Meteor. However sometimes we might need extra Babel plugins to work with. So it’s great if Meteor can support TS natively.
Sounds like it will be as simple as adding a babel plugin which Meteor already supports. Do you see special Meteor specific support being necessary? Perhaps just a shim to allow compilation of .ts/tsx using ecmascript + babel plugins?
I just updated to 1.6-beta.29 and added babel-plugin-typescript
In .babelrc file. I tried both { "presets": ["typescript"]} and { "presets": ["meteor", "typescript"]}. I also installed babel-runtime@next in node_modules. However Meteor still can’t compile ts files. There must be something tricky here.
Seamless Typescript support would be a huge win for the Meteor ecosystem; particularly with regard to refactoring, tooling, and quality control. The barbatus plugin is nice and all, but it’s sort of brittle. Having it supported in babel would basically bring it directly into the core build pipeline. Christmas in September if this pans out.
Yeah!! Also we’ll have the latest bleeding edge version of node! 1.6 FTW!!
I’m already using typescript in one project, with barbatus:typescript. Babelized typescript will be much better, but I haven’t tried to migrate yet.
For the barbus’ package:
I’ve only needed to add the package, then make a tsconfig.json, and lastly add the meteor types. Works like a charm. There’s a compile time overhead, obviously, but it’s not too much for my needs.
I’m using it in a slow-migration manner, so I have both JSX and TSX files, and both work okay with meteor without the need to add some weird black magic.
Another bump on this topic; Christmas ain’t here yet, but there is good hope there will be native support:
Quoting benjamn:
I’ve been writing more and more TypeScript lately, and I approve of this direction. I’m going to need some help validating the functionality of this typescript package, once it’s ready, but in general I plan to follow the structure of the packages/non-core/coffeescript package: separating the typescript and typescript-compiler packages, non-core, delegating to babel-compiler to avoid having to compile import and export, etc. The good news is that this doesn’t have to be tied to any Meteor release, since doesn’t need to be a “core” package.