kittencup / angular2-ama-cn

angular2 随便问
692 stars 101 forks source link

求助:ts中引用了window下的变量编译报错 #196

Closed caoren closed 8 years ago

caoren commented 8 years ago

const electron = System._nodeRequire('electron'); 编译报错 app/services/chat.ts(9,18): error TS2304: Cannot find name 'System'.

lococo--0 commented 8 years ago

试试window['System']去引用

caoren commented 8 years ago

一样的报错,这个应该是typescript的打包问题,就是不知道怎么屏蔽这种错误,生成后的js一样能运行。

lococo--0 commented 8 years ago

对 ·· 这个只是个提醒式的Err,因为window的里面没有System这个attribute,window['System']._nodeRequire('electron') 这样就不会报错了

hstarorg commented 8 years ago

declare var System;

caoren commented 8 years ago

@lococo--0 ,果然可以,非常感谢。