Skip to content

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

Closed
@scriptless

Description

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions