Typescript 角度2类型脚本编译错误TS2304?
在我的所有组件定义中的Typescript 角度2类型脚本编译错误TS2304?,typescript,angular,Typescript,Angular,在我的所有组件定义中的module.id的所有引用的typescript生成过程中出现错误TS2304。定义如下: @Component({ selector: 'sd-app', => moduleId: module.id, templateUrl: './app.component.html', directives: [ROUTER_DIRECTIVES, NavbarComponent, FooterCompone
module.id
的所有引用的typescript生成过程中出现错误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'.
编译完成,但应用程序运行良好
你知道如何消除这个错误吗
错误TS2304:找不到名称“模块”
因为TypeScript看不到在任何地方声明的变量模块
权宜之计
使用以下内容创建一个globals.d.ts
:
declare var module:any;
这将有助于给出错误引用的代码。请尝试
declare var module:any
?谢谢,有没有一种方法可以全局声明它,而不是在每个组件定义中重复?@Nexus23如果您将该行添加到主文件中(比如bootstrap.ts
),应该可以使用,但我不是百分之百确定。可能是像符咒一样的复制品。谢谢你,巴萨拉特。我已将globals.d.ts放在angular应用程序根位置,这也是用于编译的typescript文件位置。