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

DOM library in not excluded even when lib does not have dom #43929

Closed
quant-daddy opened this issue May 3, 2021 · 5 comments
Closed

DOM library in not excluded even when lib does not have dom #43929

quant-daddy opened this issue May 3, 2021 · 5 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@quant-daddy
Copy link

quant-daddy commented May 3, 2021

Bug Report

For a nodejs project, I want to exclude DOM library type definitions. I use the following compiler option

{
  "compilerOptions": {
    "lib": ["es2019", "es2020.promise", "es2020.bigint", "es2020.string"],
    "target": "es2019",
    "module": "commonjs",
    "skipLibCheck": true,
    "moduleResolution": "node",
    "allowSyntheticDefaultImports": true,
    "allowJs": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "inlineSourceMap": true,
    "importHelpers": true,
    "alwaysStrict": true,
    "strict": true,
    "outDir": "build",
    "forceConsistentCasingInFileNames": true,
    "esModuleInterop": true,
    "typeRoots": ["./node_modules/@types", "./typings"],
    "baseUrl": ".",
    "paths": {
      "#root/*": ["./*"]
    }
  },
  "include": [
    "src/**/*",
    "__tests__/**/*",
    "config/**/*",
    "scripts/bundle-test.ts"
  ],
  "exclude": ["node_modules"]
}

I have not included "dom" in the lib options but I am still getting the types from [VS Code installation folder]/code/resources/app/extensions/node_modules/typescript/lib/lib.dom.d.ts] being included in my workspace. This have lead to multiple run time errors. In particular, the parent object from Window is being included (declare var parent: Window;. Is there a way to avoid it?

@RyanCavanaugh RyanCavanaugh added the Question An issue which isn't directly actionable in code label May 3, 2021
@RyanCavanaugh
Copy link
Member

You can use tsc --explainFiles to see why this file is in your program

@quant-daddy
Copy link
Author

Thanks. It turns out there there is a package using lib.dom definition. I ended up using an eslint rule to avoid this issue:

"no-restricted-globals": [
      "error",
      {
        "name": "parent",
        "message": "Do not use window parent"
      },
      {
        "name": "name",
        "message": "Use local parameter instead."
      },
      {
        "name": "event",
        "message": "Use local parameter instead."
      },
      {
        "name": "fdescribe",
        "message": "Do not commit fdescribe. Use describe instead."
      }
    ]

@Soosay86
Copy link

Soosay86 commented May 3, 2021

https://github.com/vscode-icons/vscode-icons.wiki.git

@bluenote10
Copy link

We ran into the same issue. I have analyzed the issue and posted a more refined bug report including a reproduction example here: #43990

@typescript-bot
Copy link
Collaborator

This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

5 participants