Installing TypeScript in an existing Meteor project

Hi

How would I get TypeScript on an existing meteor project? Would anyone have explicit instructions?

I came across this package https://atmospherejs.com/adornis/typescript but it doesn’t say where the config files should go.

Thanks in advance.

Here is what is existing in the meteor documentation:

1 Like

Thanks @rjdavid I tried what the documentation says.

Now I’m having issues with importing tsx files

I’m getting the following error:

Error: Cannot find module '../components/Prototypes/HelloWorld.tsx'

I should add that saving the file as with .jsx, the import works fine.

Thanks in advance!!!

I got it to work.

TLDR

Add api.use('typescript'); to your package.js file.

If you are using Vulcan.js then here is specifically what I did.

Package.onUse(function (api) {
    api.use([
        // SASS/SCSS support
        'fourseven:scss@4.5.0',

        // vulcan core
        'vulcan:core@1.16.0',

        // vulcan packages
        'vulcan:forms@1.16.0',
        'vulcan:accounts@1.16.0',
        'vulcan:ui-bootstrap@1.16.0',
        'typescript',
    ]);
    api.addFiles('lib/stylesheets/style.scss');

    api.mainModule('lib/server/main.js', 'server');
    api.mainModule('lib/client/main.js', 'client');
});

I hope this helps someone.

Source: https://github.com/meteor/meteor/pull/10610