Skip to content

Commit a96af92

Browse files
authored
fix: explicitly type image config in ipx edge function (#1457)
1 parent 334dc40 commit a96af92

File tree

1 file changed

+6
-1
lines changed
  • plugin/src/templates/edge

1 file changed

+6
-1
lines changed

plugin/src/templates/edge/ipx.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import { Accepts } from "https://deno.land/x/[email protected]/mod.ts";
22
import type { Context } from "netlify:edge";
3+
// Available at build time
34
import imageconfig from "../functions-internal/_ipx/imageconfig.json" assert {
45
type: "json",
56
};
67

78
const defaultFormat = "webp"
89

10+
interface ImageConfig extends Record<string, unknown> {
11+
formats?: string[];
12+
}
13+
914
/**
1015
* Implement content negotiation for images
1116
*/
@@ -14,7 +19,7 @@ const defaultFormat = "webp"
1419
const handler = async (req: Request, context: Context) => {
1520
const { searchParams } = new URL(req.url);
1621
const accept = new Accepts(req.headers);
17-
const { formats = [defaultFormat] } = imageconfig;
22+
const { formats = [defaultFormat] } = imageconfig as ImageConfig;
1823
if (formats.length === 0) {
1924
formats.push(defaultFormat);
2025
}

0 commit comments

Comments
 (0)