[英]TypeScript Cannot find name 'window'
In my Meteor/React project I have the following line:在我的 Meteor/React 项目中,我有以下几行:
let gameId = window.prompt("Please enter the ID of the game you wish to load.");
TypeScript gives the transpiling error Cannot find name 'window'
. TypeScript 给出了转译错误Cannot find name 'window'
。 I am using barbatus/typescript , with default compiler options:我正在使用barbatus/typescript ,带有默认编译器选项:
{ "module": "commonjs", "target": "es5", "moduleResolution": "node", "experimentalDecorators": true, "emitDecoratorMetadata": true, "sourceMap": true }
I tried creating a tsconfig.json in the root of my Meteor project, copying the above compiler options but appending the line:我尝试在我的 Meteor 项目的根目录中创建一个 tsconfig.json,复制上述编译器选项但附加以下行:
"lib": ["es2015", "dom"]
However, the error remains.但是,错误仍然存在。
我在 tsconfig.json 的 lib compilerOptions 中添加了“dom”,然后这个问题就解决了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.