How to load System.js modules with TypeScript?

4.2k Views Asked by At

I'm trying to get TypeScript working with the default Aurelia skeleton, which is based on System.JS as a loader.

I'm having trouble getting TypeScript to accept module imports. I renamed one of the skeleton files, "nav-bar.js" to "nav-bar.ts" to see if I could convert the example into TypeScript. The code results in a compiler error: "Error:(5, 24) TS2307: Cannot find external module 'aurelia-framework'."

import {bindable} from "aurelia-framework";

export class NavBar {
  //noinspection ES6Validation
  @bindable router = null;
}

How can I get TypeScript to see the aurelia-framework as a valid import? There's a file in the root of the project called config.js that seems to describe the specific location of "aurelia-framework" but TypeScript doesn't know how to load it.

Thanks in advance for your help.

1

There are 1 best solutions below

2
On BEST ANSWER

You may want to use d.ts definition files for registration with TypeScript Definitely Typed registry for use with tsd package manager. You can find different implementations on github, for example here or here. Also this tutorial might be useful.