typescript - Angular 2 Typescript 编译错误 TS2304?

标签 typescript angular

在 typescript 构建期间,我的所有组件定义中的 module.id 的所有引用都出现错误 TS2304。定义如下:

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

这是错误:

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

编译已完成,应用程序运行正常。

知道如何消除这个错误吗?

最佳答案

error TS2304: Cannot find name 'module'

因为 TypeScript 无法看到任何地方声明的变量 module

快速修复

使用以下内容创建一个 globals.d.ts:

declare var module:any;

关于typescript - Angular 2 Typescript 编译错误 TS2304?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36319979/

相关文章:

node.js - Typescript+Node.js 中的 os.EOL

Angular - 模型和服务之间的区别

angular - 错误 : Uncaught (in promise): PushNotifications does not have web implementation

Angular/rxjs : Why don't I have to import toPromise anymore?

Angular:位置回溯历史

javascript - 带后缀的键类型

javascript - 如何解析 Angular 2中的 "_this is undefined"

angular - 无法使用 HttpClient 在 Angular 中发送 POST 请求

angular - 防止 Sentry.io 记录服务器错误代码

angular - ion-checkbox "checked"属性不起作用