简体   繁体   English

Angular 2 Typescript编译错误TS2304?

[英]Angular 2 Typescript compilation error TS2304?

Having error TS2304 during typescript build for all the references of module.id in all of my components definitions. 在我所有组件定义中的module.id的所有引用的打字稿构建期间出现错误TS2304。 Definition looks like this: 定义如下所示:

    @Component({
        selector: 'sd-app',
   =>   moduleId: module.id,
        templateUrl: './app.component.html',
        directives: [ROUTER_DIRECTIVES, NavbarComponent, FooterComponent],
        providers: [AuthService]
    })

Here is the error: 这是错误:

app\components\app.component.ts(15,15): error TS2304: Cannot find name 'module'.

Compilation completes and application works fine though. 编译完成并且应用程序运行正常。

Any idea how to get rid of this error? 任何想法如何摆脱这个错误?

error TS2304: Cannot find name 'module' 错误TS2304:找不到名称“模块”

Because TypeScript cannot see the variable module declared anywhere. 因为TypeScript在任何地方都看不到声明的变量module

Quickfix 快速解决

Create a globals.d.ts with the following: 使用以下命令创建一个globals.d.ts

declare var module:any;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM