无论哪种情况:
document.getElementById('body');
// or
window.document.getElementById('body');
我得到error TS2304: Cannot find name 'window'.
分
对于我应该安装的定义文件,我是否在tsconfig.json
中遗漏了什么?
我在跑tsc
分和vscode
分时得到了这个信息
tsconfig.json:
{
"compilerOptions": {
"allowJs": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"jsx": "react",
"module": "commonjs",
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": false,
"sourceMap": true,
"suppressImplicitAnyIndexErrors": true,
"target": "ES2016",
"typeRoots": [
"node_modules/@types/",
"typings/index.d.ts"
]
},
"exclude": [
"node_modules",
"**/*-aot.ts"
]
}
我的回答是: