Meteor 1.7 with TypeScript?

I’m trying to use the barbatus:typescript package with Meteor 1.7. However, even before converting any files from .js to .ts, I’m running into a problem where Meteor’s global imports (Session, Accounts, Mongo, etc.) sometimes fail, and also imports of Atmosphere packages sometimes fail.

For example, importing meteor:reactive-dict fails with Cannot find module 'meteor/reactive-dict'. Strangely, I can import meteor:session, but the package returns an empty object {}.

This fails in both .js and .ts files. I’ve installed @types/meteor from NPM. I’m not sure what’s wrong.

Has anyone gotten Meteor 1.7 working with TypeScript? I also can’t find any working examples.

It sounds like you’re not importing correctly. It should be

import { ReactiveDict } from 'meteor/reactive-dict'

etc.

Yep, that’s what I’m doing. To give more context, I had a fully working app before trying to integrate typescript. The imports only stopped working after installing the typescript package.

I’ve realized that the problem is because TypeScript (or ES6?) doesn’t allow for dynamic importing, which I had relied on before. Switching to TypeScript meant that imports that were previously being ignored on the serverwere now imported (but not run) on the server, causing problems. I’m not sure of a clean solution, and I would like to be able to keep maxing things (as client-server code sharing is one of Meteor’s big strengths), but isolating things fixed the problem.