Reputation: 149
In my Meteor/React project I have the following line:
let gameId = window.prompt("Please enter the ID of the game you wish to load.");
TypeScript gives the transpiling error Cannot find name 'window'
.
I am using barbatus/typescript, with default compiler options:
{
"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:
"lib": ["es2015",
"dom"]
However, the error remains.
Upvotes: 1
Views: 8771
Reputation: 1
In addition to the answer above in your tsconfig file, you need to set the "lib" property to include "dom".
{
"compilerOptions": {
// rest of your config
"lib": ["dom"] // Add this line
}
}
Upvotes: 0
Reputation: 21
I added "dom" to the lib compilerOptions in tsconfig.json,then this problem has been resolved.
Upvotes: 2