Will TypeScript support be added to Meteor 1.6?

#1


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.

From babel-compiler README it says

Any plugins and transforms that you list in your .babelrc file will be included after babel-preset-meteor.

It means we are not able to use babel-preset-typescript before babel-preset-meteor. Do you have any ideas?

2 Likes
#2

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?

#3

@hexsprite I don’t think it would be quite easy.

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.

#4

omg, is it Christmas in September???

1 Like
#5

@awatson1978 LUL?? I don’t get it.

#6

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.

3 Likes
#7

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.

Here’s my tsconfig.json:

{
  "compilerOptions": {
    "target":"es5",
    "module": "commonjs",
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "sourceMap": true,
    "lib": [
      "es2015", "dom"
    ],
    "types": ["meteor-typings"],
    "jsx": "react",
    "allowJs": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "suppressImplicitAnyIndexErrors": true,
    "allowSyntheticDefaultImports": true
  }
}
4 Likes
#8

Bumping a slightly old thread, but I’ve put together a package to compile TypeScript via Babel in Meteor 1.6.1: Babel TypeSript Compiler released

2 Likes
#9

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.