aboutsummaryrefslogtreecommitdiff
path: root/src/util/sharp-shim.ts
diff options
context:
space:
mode:
authoramankumarsingh77 <amankumarsingh7702@gmail.com>2026-07-28 20:23:12 +0530
committerAman Kumar <145339995+amankumarsingh77@users.noreply.github.com>2026-08-02 19:12:46 +0530
commit12d7a38ba0f1b1e4e301fce81e22f4b93036d211 (patch)
tree003ad2b341e887dd7e102d0b1dad9f580bdef70a /src/util/sharp-shim.ts
parent2b3eb8ad79d2fed770cf665cff1cc746951a95d3 (diff)
refactor(util): strip comment noise
Removes file-header banners and comments that restate the code. Keeps one-line notes at the optional-sharp dynamic import, the sharp .default probe, the `never` contravariance trick, the sanctioned renderCall cast, and safeJs's interpolation rule. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'src/util/sharp-shim.ts')
-rw-r--r--src/util/sharp-shim.ts11
1 files changed, 2 insertions, 9 deletions
diff --git a/src/util/sharp-shim.ts b/src/util/sharp-shim.ts
index 36dd536..d7adb5f 100644
--- a/src/util/sharp-shim.ts
+++ b/src/util/sharp-shim.ts
@@ -1,10 +1,4 @@
-// Typed minimal shim for the optional `sharp` dependency. Sharp is a heavy
-// native module not installed in every workspace; we import dynamically and
-// distinguish "missing" (no install) from "error" (installed but threw).
-//
-// We declare only the surface we use. The dynamic import returns `unknown`
-// at the boundary; the cast inside loadSharp() is the documented escape
-// hatch — every other consumer sees the typed SharpFactory.
+// `sharp` is an optional dependency not installed in every workspace, so the import must stay dynamic and unresolvable to tsc.
export type SharpInstance = {
metadata(): Promise<{ width?: number; height?: number }>;
@@ -38,8 +32,7 @@ export const loadSharp = async (): Promise<SharpLoad> => {
return { kind: "error", message: msg };
}
if (mod === null || mod === undefined) return { kind: "missing" };
- // The CommonJS sharp module's default export IS the factory. ESM-wrapped
- // sharp puts it on .default. Probe both.
+ // The CommonJS sharp module's default export IS the factory; ESM-wrapped sharp puts it on .default.
const m = mod as { default?: unknown };
const candidate: unknown = typeof m.default === "function" ? m.default : mod;
if (typeof candidate !== "function") {