Я определил следующий компонент Angular2:
import {Component} from 'angular2/core';
@Component({
selector: 'my-app',
moduleId: module.id,
templateUrl: './app.component.html'
})
export class AppComponent {
}
Когда я пытаюсь скомпилировать это, я получаю следующую ошибку в строке 5:
src/app/app.component.ts(5,13): error TS2304: Cannot find name 'module'.
Я считаю, что module.id ссылается на переменную CommonJS module
(см. здесь). Я указал систему модуля CommonJS в tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"declaration": false,
"removeComments": true,
"noLib": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"pretty": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitUseStrict": false,
"noFallthroughCasesInSwitch": true
},
"exclude": [
"node_modules",
"dist",
"typings/browser.d.ts",
"typings/browser",
"src"
],
"compileOnSave": false
}
Как исправить ошибку TypeScript?