TypeScript: Duplicate identifier error caused by lib.dom.d.ts

TypeScript Version: 3.7.3 & 3.8.0-dev.20191207

Search Terms: Duplicate identifier, lib.dom.d.ts Code

/// <reference types="node" />
declare global {
    class URL {
        hash: string;
        host: string;
        hostname: string;
        href: string;
        password: string;
        pathname: string;
    }
}
{
  "compilerOptions": {
    "target": "ESNEXT",
    "module": "commonjs",
    "allowJs": true,
    "checkJs": true,
    "strict": true,
    "noImplicitAny": true,
    "moduleResolution": "node",
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "forceConsistentCasingInFileNames": true
  },
  "files": ["./index.d.ts"]
}

Actually I’ve tried various tsconfig options, including target es6, with

  "exclude": [
    "node_modules",
    "node_modules/typescript/lib/lib.dom.d.ts"
  ]

but nothing helped.

Expected behavior:

No error during compilation should be thrown. Or at list it should respect tsconfig exclude section and not use that lib.dom.d.ts if it’s excluded.

Actual behavior:

node_modules/typescript/lib/lib.dom.d.ts:16073:11 - error TS2300: Duplicate identifier 'URL'.

Related Issues: https://github.com/microsoft/TypeScript/issues/20595 https://github.com/Microsoft/TypeScript/issues/5585 https://github.com/microsoft/TypeScript/issues/4168 https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34960

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (1 by maintainers)

Most upvoted comments

Any news on how to fix this?