fix: resolve Sharp 0.35.1 and BullMQ type incompatibilities after dep bumps

Sharp 0.35.1 moved FormatEnum to a namespace export and removed "avif"
from FormatEnum (now a separate literal in toFormat). BullMQ 5.78.1
bundles ioredis 5.10.1 while we have 5.11.1, causing structural type
mismatch. Also fixes new Biome 1.9 lint rules.
This commit is contained in:
SnapOtter
2026-06-15 15:20:16 +08:00
parent 9a61cb6af1
commit b76dc68682
18 changed files with 62 additions and 50 deletions
@@ -31,7 +31,7 @@ export async function compress(image: Sharp, options: CompressOptions): Promise<
const safeDetected = NO_ENCODER.has(detected) ? "png" : detected;
const outputFormat = (FORMAT_MAP[format ?? ""] ??
FORMAT_MAP[safeDetected] ??
safeDetected) as keyof import("sharp").FormatEnum;
safeDetected) as keyof sharp.FormatEnum;
if (targetSizeBytes !== undefined) {
if (targetSizeBytes <= 0) {
@@ -52,7 +52,7 @@ export async function compress(image: Sharp, options: CompressOptions): Promise<
async function findBestQuality(
inputBuffer: Buffer,
resize: { width: number; height: number } | null,
format: keyof import("sharp").FormatEnum,
format: keyof sharp.FormatEnum,
targetBytes: number,
): Promise<number | null> {
let low = 1;
@@ -82,7 +82,7 @@ async function findBestQuality(
async function compressToTargetSize(
inputBuffer: Buffer,
format: keyof import("sharp").FormatEnum,
format: keyof sharp.FormatEnum,
targetBytes: number,
): Promise<Sharp> {
const quality = await findBestQuality(inputBuffer, null, format, targetBytes);
@@ -1,3 +1,4 @@
import type sharp from "sharp";
import type { ConvertOptions, Sharp } from "../types.js";
/**
@@ -31,5 +32,5 @@ export async function convert(image: Sharp, options: ConvertOptions): Promise<Sh
formatOptions.quality = quality;
}
return image.toFormat(sharpFormat as keyof import("sharp").FormatEnum, formatOptions);
return image.toFormat(sharpFormat as keyof sharp.FormatEnum, formatOptions);
}