This package allows Meteor to compile TypeScript files with Babel.
lmachens:ecmascript-ts
will register a new compiler for .ts
and .tsx
files. It uses the same BabelCompiler ecmascript
package is using.
meteor add lmachens:ecmascript-ts
meteor npm install --save-dev @babel/preset-typescript
Make sure your .babelrc has the @babel/preset-typescript
preset:
{
"presets": [
"@babel/env",
"@babel/preset-typescript"
]
}
Meteor will now compile .ts
and .tsx
files with the babel compiler.
Note that Babel will not perform type-checking on Typescript code.
You still need TypeScript to read from .d.ts
files.
This can be done by a separate tsc --watch
task or in some tests.
meteor npm install --save-dev typescript
Add these scripts to your package.json:
{
"scripts": {
"test-types": "tsc",
"watch-types": "tsc --watch"
}
}
It is recommended to install Meteor type definitions:
meteor npm install --save-dev @types/meteor
There is a good article which describes how Babel and TypeScript works together. And there is a discussion in the meteor-feature-requests.