From e1bc270830f2fc2df3542d4ef4c61b916c802df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C5=A9=20V=C4=83n=20D=C5=A9ng?= Date: Mon, 11 Sep 2023 21:14:39 +0700 Subject: [PATCH] Ensure `ImageResponse` extends `Response` (#55187) ### Why? The `ImageResponse` class constructor returns a `Response` instance, but doesn't extend `Response`, so it doesn't pass the type check introduced in #51394. ### How? Make the `ImageResponse` class a subclass of `Response`. ### Notes I can't find any tests to check for the types so didn't add any tests here; but shouldn't there be one? --- packages/next/src/server/web/spec-extension/image-response.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/next/src/server/web/spec-extension/image-response.ts b/packages/next/src/server/web/spec-extension/image-response.ts index d4d7c22a10846..bedf93ad0400d 100644 --- a/packages/next/src/server/web/spec-extension/image-response.ts +++ b/packages/next/src/server/web/spec-extension/image-response.ts @@ -1,4 +1,4 @@ -export class ImageResponse { +export class ImageResponse extends Response { public static displayName = 'NextImageResponse' constructor( ...args: ConstructorParameters< @@ -36,7 +36,7 @@ export class ImageResponse { const options = args[1] || {} - return new Response(readable, { + super(readable, { headers: { 'content-type': 'image/png', 'cache-control':