Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript can't find a module that has been mapped with SystemJS

Tags:

Typescript doesn't find the module in this import import ga from 'googleAnalytics';

SystemJS knows where to find the module, because it has been mapped up front like so:

map: {
    '@angular': 'node_modules/@angular',
    'rxjs': 'node_modules/rxjs',
    'underscore': 'node_modules/underscore/underscore-min.js',
    'googleAnalytics': '//www.google-analytics.com/analytics.js'
},

How can I provide similar mapping to the tsc?

This other question seems to point in a good direction: How to avoid imports with very long relative paths in Angular 2?

Typescript 2.0 seems to support the paths config for the tsconfig.json. Is there a way to download Typescript 2.0? Can I give the path config an http url (//www.google-analytics.com/analytics.js) like I'm doing with SystemJS? If there is no way to download Typescript 2.0, how can I achieve what I want with the current version?

Edit

The specific error I get is: "Cannot find module 'ga'".

Here is my tsconfig.json:

{
    "compilerOptions": {
        "rootDir": "./",
        "target": "es5",
        "module": "system",
        "moduleResolution": "node",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "noImplicitAny": true
    },
    "exclude": [
        "node_modules",
        "front-end/node_modules",
        "typings/main",
        "typings/main.d.ts"
    ]
}