Cannot find name 'document', 'window', ... Do you need to change your target library?
See original GitHub issueInfo
- Platform: Win 10
- Vetur version: 0.23.0
- VS Code version: 1.41.1
Problem
Using Typescript.
What I done:
- added dom to lib in tsconfig.json
- check tsconfig.json for errors
- reinstalled vetur, restarted vscode
Seems like simple dom objects/methods are unknown to Vetur even when DOM is defined in lib.
tsconfig.json:
{
"compileOnSave": false,
"buildOnSave": false,
"atom": {
"rewriteTsconfig": false
},
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"alwaysStrict": true,
"baseUrl": "./",
"charset": "utf8",
"declaration": false,
"diagnostics": false,
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"locale": "en",
"module": "commonjs",
"moduleResolution": "node",
"newLine": "lf",
"noEmit": false,
"noEmitHelpers": false,
"noEmitOnError": false,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": false,
"noImplicitUseStrict": false,
"noUnusedLocals": true,
"noUnusedParameters": false,
"pretty": true,
"removeComments": true,
"resolveJsonModule": true,
"sourceMap": false,
"strictNullChecks": false,
"target": "es2016",
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"es2017",
"es2016",
"es2015",
"esnext",
"dom"
],
},
"include": [
"src/*",
],
"exclude": [
"node_modules"
]
}
Reproducible Case
Test application: https://github.com/scriptlessatwork/test-app For example using document.* or window.* methods in a Vue component method. Language is Typescript.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Typescript cannot find name window or document
I get error TS2304: Cannot find name 'window'. Am I missing something in tsconfig.json for a definition file I should install? I get...
Read more >Cannot find name 'window' or 'document' in TypeScript
To solve the "Cannot find name window or document " error, add dom to the lib array in your tsconfig.json file. The dom...
Read more >(Solved) Cannot find name '..'. Do you need to change your target ...
Cannot find name 'window'. Cannot find name 'document'. Do you need to change your target library? Try changing the lib compiler option to...
Read more >Cannot find name 'document' error when building plugin UI ...
There is a solution described in the error message you sent: Do you need to change your target library? Try changing the 'lib'...
Read more >Neovim's native LSP with tsserver - "Cannot find name ...
Neovim's native LSP with tsserver - "Cannot find name document. Do you need to change your target library?" Unsure if Neovim is reading...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Seems like its actually working now, I didnt found the issue
So I found out that the error messages dont exist on my Macbook while on my main computer (Windows 10) it shows those errors. I’m using vscode settings sync, so they should have the same settings. Weird.