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"
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With