Skip to content

URL getters (etc.) now returning ArrayBufferView and not string #1818

@Cherry

Description

@Cherry

In the latest workers-types release, some return types are being typed as ArrayBufferView instead of string, such as the getters on URL objects.

Reference: https://npmdiff.dev/@cloudflare%2fworkers-types/4.20240222.0/4.20240312.0/package/2023-07-01/index.d.ts/
Or full source diff: Cloudflare-Mining/Cloudflare-Datamining@f3eb65c
image

Previously worked:

export default {
	async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
		const url = new URL(request.url);
		const urlWithHostname = url.hostname + url.pathname;
		return new Response(urlWithHostname);
	},
};

Now it errors with:
Operator '+' cannot be applied to types 'ArrayBufferView' and 'ArrayBufferView'.ts(2365)

This also impacts getters on URLSearchParams. I would guess these unintentional changes are due to some of the changes with ada url implementation, but I'm not confident.

Metadata

Metadata

Labels

typesRelated to @cloudflare/workers-types

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions