I'm currently in the process of familiarizing myself with Typescript. Specifically, I am developing an Angular 2
application using typescript 2
and employing SystemJS 0.15.31
as my module loader.
My goal is to establish constants that are accessible throughout my entire application by defining them in a single file and importing them into individual components when necessary. Here's what I've implemented:
root/systemjs.config.js
System.config({
map:{
'app': 'dist',
'config': 'dist/config',
...
}
});
root/dev/config.ts
export module Config {
var version:string = '1';
}
root/dev/app/app.component.ts
import {Config} from 'config';
...
export class AppComponent {
...
version = Config.version;
}
However, after transpiling to Javascript and placing the .ts
files in dist/
, I encounter an error displayed by the typescript compiler on the first line of app.component.ts
. Additionally, in the browser, the AppComponent
does not recognize Config.version
.
error TS2307: Cannot find module 'config'.
What could be causing this issue with my syntax?