From e9158c72631d6cbe5e025dd38a1f314bb12ca0d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Tue, 2 May 2023 10:31:27 +0200 Subject: [PATCH 1/3] fix(ts): make `ReadonlyHeaders` more compatible with `Headers` --- .../src/server/web/spec-extension/adapters/headers.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/next/src/server/web/spec-extension/adapters/headers.ts b/packages/next/src/server/web/spec-extension/adapters/headers.ts index c5e9d2bd35a4f..828e599b061d4 100644 --- a/packages/next/src/server/web/spec-extension/adapters/headers.ts +++ b/packages/next/src/server/web/spec-extension/adapters/headers.ts @@ -17,8 +17,14 @@ export class ReadonlyHeadersError extends Error { } } -export type ReadonlyHeaders = Omit - +export type ReadonlyHeaders = Headers & { + /** @deprecated Method unavailable on ReadonlyHeaders. Read more: https://beta.nextjs.org/docs/api-reference/cookies */ + append(...args: any[]): never + /** @deprecated Method unavailable on ReadonlyHeaders. Read more: https://beta.nextjs.org/docs/api-reference/cookies */ + set(...args: any[]): never + /** @deprecated Method unavailable on ReadonlyHeaders. Read more: https://beta.nextjs.org/docs/api-reference/cookies */ + delete(...args: any[]): never +} export class HeadersAdapter extends Headers { private readonly headers: IncomingHttpHeaders From 50096f9c875508a4b90c2411af44997d0e192f68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Tue, 2 May 2023 10:44:59 +0200 Subject: [PATCH 2/3] syntax highlight --- .../next/src/server/web/spec-extension/adapters/headers.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/next/src/server/web/spec-extension/adapters/headers.ts b/packages/next/src/server/web/spec-extension/adapters/headers.ts index 828e599b061d4..87bcb3d7e4e2d 100644 --- a/packages/next/src/server/web/spec-extension/adapters/headers.ts +++ b/packages/next/src/server/web/spec-extension/adapters/headers.ts @@ -18,11 +18,11 @@ export class ReadonlyHeadersError extends Error { } export type ReadonlyHeaders = Headers & { - /** @deprecated Method unavailable on ReadonlyHeaders. Read more: https://beta.nextjs.org/docs/api-reference/cookies */ + /** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://beta.nextjs.org/docs/api-reference/cookies */ append(...args: any[]): never - /** @deprecated Method unavailable on ReadonlyHeaders. Read more: https://beta.nextjs.org/docs/api-reference/cookies */ + /** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://beta.nextjs.org/docs/api-reference/cookies */ set(...args: any[]): never - /** @deprecated Method unavailable on ReadonlyHeaders. Read more: https://beta.nextjs.org/docs/api-reference/cookies */ + /** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://beta.nextjs.org/docs/api-reference/cookies */ delete(...args: any[]): never } export class HeadersAdapter extends Headers { From 6b188e719debfad42b6b5d3df9a2a9b3a9f80885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Tue, 2 May 2023 11:09:24 +0200 Subject: [PATCH 3/3] fix return type, and link --- .../server/web/spec-extension/adapters/headers.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/next/src/server/web/spec-extension/adapters/headers.ts b/packages/next/src/server/web/spec-extension/adapters/headers.ts index 87bcb3d7e4e2d..88d2e65363708 100644 --- a/packages/next/src/server/web/spec-extension/adapters/headers.ts +++ b/packages/next/src/server/web/spec-extension/adapters/headers.ts @@ -18,12 +18,12 @@ export class ReadonlyHeadersError extends Error { } export type ReadonlyHeaders = Headers & { - /** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://beta.nextjs.org/docs/api-reference/cookies */ - append(...args: any[]): never - /** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://beta.nextjs.org/docs/api-reference/cookies */ - set(...args: any[]): never - /** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://beta.nextjs.org/docs/api-reference/cookies */ - delete(...args: any[]): never + /** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://nextjs.org/docs/api-reference/headers */ + append(...args: any[]): void + /** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://nextjs.org/docs/api-reference/headers */ + set(...args: any[]): void + /** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://nextjs.org/docs/api-reference/headers */ + delete(...args: any[]): void } export class HeadersAdapter extends Headers { private readonly headers: IncomingHttpHeaders