-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
fix: deprecate URL as the first arg of fetch #14113
Conversation
This change does affect me. In some deno projects I've worked on, it does use a URL instead of a URL string as the first argument to fetch. Perhaps, this PR should be an rf rather than a fix. |
@iugo Does rf mean 'refactor'? BTW this doesn't change runtime. |
Although not a design refactoring of whatwg.fetch, this should be a design refactoring of deno ext/fetch. Yes, just deprecate instead of remove helped us a lot. We'll adjust the code accordingly soon. Also, to follow the whatwg standard more strictly, the first argument to fetch should start with " "about", "blob", "data", "file", "http" or "https". https://fetch.spec.whatwg.org/#url |
That might make sense, but probably we don't want to follow that in typing because we don't want to diverge our Some applications use |
This was a breaking change. My project does not compile anymore with 1.20.3 but it still does with 1.20.2. I understand that performing breaking changes in patch releases is attractive to do, but please somehow label this in your changelog next time. Try deno cache https://deno.land/x/grammy@v1.7.0/mod.ts with the two versions to confirm. |
It looks like this broke things, yeah. Consider the following: > deno install -qAn vr https://deno.land/x/velociraptor@1.4.0/cli.ts
error: TS2769 [ERROR]: No overload matches this call.
Overload 1 of 2, '(input: string | Request, init?: RequestInit | undefined): Promise<Response>', gave the following error.
Argument of type 'string | URL | Request' is not assignable to parameter of type 'string | Request'.
Type 'URL' is not assignable to type 'string | Request'. Overload 2 of 2, '(input: URL, init?: RequestInit | undefined): Promise<Response>', gave the following error.
Argument of type 'string | URL | Request' is not assignable to parameter of type 'URL'.
Type 'string' is not assignable to type 'URL'.
const promise = fetch(url, { signal: controller.signal });
~~~
at https://arweave.net/e-arTRJlkythqLWvvPw09-2ZJU1rIS3l3asHysflhK0/lib/utilities/utils.ts:13:25
> deno --version
deno 1.20.3 (release, x86_64-apple-darwin)
v8 10.0.139.6
typescript 4.6.2 I was able to work around the issue by using the |
It will be fixed in the upcoming release |
Oh, I didn't realize this change breaks those cases... Thank you for reporting! @KnorpelSenf @bebraw @nayeemrmn Thank you for your fix! |
Deno's fetch and lib.dom's fetch have slightly different declarations. (Deno's fetch accept URL as the first arg, but lib.dom's fetch doesn't)
We should align Deno's declaration to lib.dom's (spec defines first arg as
typedef (Request or USVString) RequestInfo
ref) to reduce the confusion.This PR tries to deprecate Deno-only signature of fetch function.
With this change, fetch with URL call gets strikethrough style in vscode like the below