question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find name 'document', 'window', ... Do you need to change your target library?

See original GitHub issue
  • I have searched through existing issues
  • I have read through docs
  • I have read FAQ

Info

  • 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:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
scriptlesscommented, Jan 15, 2020

Seems like its actually working now, I didnt found the issue

0reactions
scriptlesscommented, Jan 15, 2020

Is it really reproducible case on your end? I could not see any errors on it. Also it does not have tsconfig.json which you stated in the original post. Screenshot 2020-01-15 at 7 17 00 PM

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found