Skip to content

Commit

Permalink
Ensure ImageResponse extends Response (#55187)
Browse files Browse the repository at this point in the history
### 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?
  • Loading branch information
joulev authored Sep 11, 2023
1 parent 80654c1 commit e1bc270
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/next/src/server/web/spec-extension/image-response.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export class ImageResponse {
export class ImageResponse extends Response {
public static displayName = 'NextImageResponse'
constructor(
...args: ConstructorParameters<
Expand Down Expand Up @@ -36,7 +36,7 @@ export class ImageResponse {

const options = args[1] || {}

return new Response(readable, {
super(readable, {
headers: {
'content-type': 'image/png',
'cache-control':
Expand Down

0 comments on commit e1bc270

Please sign in to comment.