Skip to content

TypeScript compilation fails for mixed node/web project due to conflict with @types/node "url" module #33

@forshtat

Description

@forshtat

Expected Behavior

I expected 'native-url' to be a drop-in replacement for the URL class available in Node for files that are used in the web browser only.

Actual Behavior

TypeScript compilation fails with

node_modules/@types/node/url.d.ts:76:11 - error TS2300: Duplicate identifier 'URL'.

76     class URL {
             ~~~

  node_modules/native-url/third_party/url.d.ts:100:9
    100   class URL {
                ~~~
    'URL' was also declared here.

Steps to Reproduce the Problem

  1. Create a TypeScript project with both '@types/node' and 'native-url' installed
  2. Try to compile it

So far I could only workaround by mapping the declarations for 'native-url' to some bogus file by adding to the tsconfig.json the following lines:

    "baseUrl": ".",
    "paths": {
      "native-url": ["types/native-url"]
    }

I wonder if there is a better solution, or if I am doing it all wrong, or if this should be addressed by the maintainers of the library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions