我定义了以下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指的是CommonJSmodule
变量(请参阅此处)。我在tsconfig.json中指定了CommonJS模块系统:
{
"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错误?