How to load System.js modules using TypeScript?

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

I'm having trouble getting TypeScript to import modules. I renamed one of the skeleton files "nav-bar.js" to "nav-bar.ts" to see if I can convert this example to TypeScript. As a result of the code, a compiler error occurs: "Error: (5, 24) TS2307: the external module" aurelia-framework "cannot be found.

import {bindable} from "aurelia-framework"; export class NavBar { //noinspection ES6Validation @bindable router = null; } 

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

Thanks in advance for your help.

+6
source share
1 answer

You can use the d.ts definition d.ts to register with TypeScript. A definitely typed registry for use with the tsd package manager. You can find various implementations on github, for example here or here . It is also useful to use a tutorial .

+5
source

Source: https://habr.com/ru/post/988968/


All Articles