oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.27k stars 2.77k forks source link

`parse` does not exist on URL #13858

Open camc314 opened 2 months ago

camc314 commented 2 months ago

What version of Bun is running?

1.1.26+0a37423ba

What platform is your computer?

Darwin 23.6.0 arm64 arm

What steps can reproduce the bug?

access the parse property of URL

What is the expected behavior?

it's typed correctly something like the lib types:

    /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static) */
    parse(url: string | URL, base?: string | URL): URL | null;

What do you see instead?

<file name>:919:5 - error TS2339: Property 'parse' does not exist on type '{ new (url: string | URL, base?: string | URL | undefined): URL; prototype: URL; canParse(url: string | URL, base?: string | undefined): boolean; createObjectURL(obj: Blob | MediaSource): string; revokeObjectURL(url: string): void; }'.

919 URL.parse;

Additional information

This function exists:

bun repl
Welcome to Bun v1.1.26
Type ".help" for more information.
[!] Please note that the REPL implementation is still experimental!
    Don't consider it to be representative of the stability or behavior of Bun overall.
> typeof URL.parse
'function'
> 
camc314 commented 1 month ago

I believe #13987 would fix this issue

nektro commented 4 weeks ago

still nailing down whether this is a local typescript issue or a @type/node dependency issue

added to standard here (Mar 25) https://github.com/whatwg/url/commit/58acb06dccec3e95a33d842337e61d25195d4b1b

added to typescript here (Jul 18) (v5.6.2) https://github.com/microsoft/TypeScript/commit/121c5dd36bd87e47a065ff7d6b220ce6d079075c

added to @types/node here (Aug 2) https://github.com/DefinitelyTyped/DefinitelyTyped/commit/072b51aeb4be191aad361aa8c98e09108cf9b886

added to node here (Apr 13) (v23.0.0) https://github.com/nodejs/node/commit/8b4c4e825cf69d1edb7838730c553d4aa4b52235

camc314 commented 3 weeks ago

yeah i think this is a @types/mode deps issue - in some other project that do not depend on @types/bun, they do not have this issue, parse (correctly) exists on URL

i think this should be rechecked once #13987 is merged as i believe that will fix the issue