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

URL type conflicts with @types/node's URL type #17470

Open
TheEssem opened this issue Feb 20, 2025 · 0 comments
Open

URL type conflicts with @types/node's URL type #17470

TheEssem opened this issue Feb 20, 2025 · 0 comments
Assignees
Labels
bug Something isn't working types An issue with TypeScript types

Comments

@TheEssem
Copy link

What version of Bun is running?

1.2.2+c1708ea6a

What platform is your computer?

Linux 6.13.3-2-cachyos x86_64 unknown

What steps can reproduce the bug?

When attempting to assign a value to an existing variable of type URL using new URL(), the resulting types conflict with each other.

Steps to reproduce:

  1. Add the @types/bun, @tsconfig/node20, and @types/node packages to a project
  2. Use a tsconfig.json file with the following contents:
{
  "extends": "@tsconfig/node20/tsconfig.json",
  "compilerOptions": {
    "module": "NodeNext",
    "moduleResolution": "nodenext",
    "outDir": "./dist",
    "rootDir": "./src",
    "allowJs": true,
    "resolveJsonModule": true
  },
  "include": ["./src/**/*"],
  "exclude": ["./dist/**/*"]
}
  1. Attempt to build the following TypeScript code, e.g. using tsc:
let imageURL: URL | null = null;
try {
  imageURL = new URL("https://bun.sh");
} catch {
  console.error("fail");
}
console.log(imageURL);

What is the expected behavior?

The build should succeed without any errors.

What do you see instead?

The TypeScript compiler throws the following error with code TS2739: Type 'URL' is missing the following properties from type 'URL': createObjectURL, revokeObjectURL, canParse

Additional information

I noticed that the mentioned properties all happen to be static methods; I took a look and found that the Bun types expose them as regular instance methods, which is inaccurate.

@TheEssem TheEssem added bug Something isn't working types An issue with TypeScript types labels Feb 20, 2025
TheEssem added a commit to esmBot/esmBot that referenced this issue Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working types An issue with TypeScript types
Projects
None yet
Development

No branches or pull requests

2 participants