Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3 tasks done
scriptless opened this issue Jan 14, 2020 · 8 comments
Closed
3 tasks done

Comments

@scriptless
Copy link

scriptless commented Jan 14, 2020

  • 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.

@ktsn
Copy link
Member

ktsn commented Jan 14, 2020

Could you provide self-contained reproduction?
See about reproduction: https://new-issue.vuejs.org/?repo=vuejs/vue#why-repro

@scriptless
Copy link
Author

Could you provide self-contained reproduction?
See about reproduction: https://new-issue.vuejs.org/?repo=vuejs/vue#why-repro

Added

@ktsn
Copy link
Member

ktsn commented Jan 14, 2020

Did you read the link I posted? Text is not a reproduction as we cannot exactly confirm the issue from it. You can provide minimal example project, reproducing the issue, as GitHub repository, for example.

@scriptless
Copy link
Author

Did you read the link I posted? Text is not a reproduction as we cannot exactly confirm the issue from it. You can provide minimal example project, reproducing the issue, as GitHub repository, for example.

Added a minimal test app. The path to the file with the error is src/components/HelloWorld.vue
There is also a screenshot shown the problem in the file.

@ktsn
Copy link
Member

ktsn commented 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

@scriptless
Copy link
Author

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.

@scriptless
Copy link
Author

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

@plastic-shurikens
Copy link

Might be a late reply but adding "DOM" to lib in compilerOptions solved it for me

{ "compilerOptions": { "target": "es5", "module": "commonjs", "lib": ["es6", "DOM"], "allowJs": true, "outDir": "build", "rootDir": "src", "strict": true, "esModuleInterop": true, "types": ["node", "jest"], "skipLibCheck": true, "resolveJsonModule": true, "downlevelIteration": true, },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants