Skip to content

Commit 182ac0d

Browse files
committed
fix typing issue
1 parent 5ad3ee1 commit 182ac0d

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

packages/open-next/src/adapters/plugins/image-optimization/image-optimization.replacement.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import type { APIGatewayProxyEventHeaders } from "aws-lambda";
44
import type { NextConfig } from "next/dist/server/config-shared";
55
//#override imports
66
import {
7-
// @ts-ignore
87
fetchExternalImage,
9-
// @ts-ignore
108
fetchInternalImage,
119
imageOptimizer,
1210
} from "next/dist/server/image-optimizer";
@@ -32,13 +30,12 @@ export async function optimizeImage(
3230
? await fetchExternalImage(href)
3331
: await fetchInternalImage(
3432
href,
35-
// @ts-ignore
33+
// @ts-expect-error - It is supposed to be an IncomingMessage object, but only the headers are used.
3634
{ headers },
3735
{}, // res object is not necessary as it's not actually used.
3836
handleRequest,
3937
);
4038

41-
// @ts-ignore
4239
const result = await imageOptimizer(
4340
imageUpstream,
4441
imageParams,

packages/open-next/src/adapters/plugins/image-optimization/image-optimization.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ export async function optimizeImage(
2121
) => Promise<void>,
2222
) {
2323
const result = await imageOptimizer(
24-
// @ts-ignore
2524
{ headers },
2625
{}, // res object is not necessary as it's not actually used.
2726
imageParams,
2827
nextConfig,
2928
false, // not in dev mode
30-
// @ts-ignore
29+
// @ts-expect-error - This file is used only for Next 14.1 and below. Typing is correct for these versions.
3130
handleRequest,
3231
);
3332
debug("optimized result", result);

packages/open-next/src/http/openNextResponse.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export interface StreamCreator {
2525
}
2626

2727
// We only need to implement the methods that are used by next.js
28-
// @ts-ignore
2928
export class OpenNextNodeResponse extends Transform implements ServerResponse {
3029
statusCode!: number;
3130
statusMessage: string = "";
@@ -324,6 +323,18 @@ export class OpenNextNodeResponse extends Transform implements ServerResponse {
324323
callback();
325324
}
326325

326+
/**
327+
* New method in Node 18.15+
328+
* There are probably not used right now in Next.js, but better be safe than sorry
329+
*/
330+
331+
setHeaders(headers: Headers | Map<string, number | string | readonly string[]>): this {
332+
headers.forEach((value, key) => {
333+
this.setHeader(key, Array.isArray(value) ? value : value.toString());
334+
})
335+
return this;
336+
}
337+
327338
/**
328339
* Next specific methods
329340
* On earlier versions of next.js, those methods are mandatory to make everything work

0 commit comments

Comments
 (0)