The open source coding agent.
TypeScript
fix(opencode): skip typechecking generated models snapshot (#19018)
Kit Langton50f6aa37638d
diff --git a/packages/opencode/script/build.ts b/packages/opencode/script/build.tsindex a97cf324961..4a94bf6c3e9 100755--- a/packages/opencode/script/build.ts+++ b/packages/opencode/script/build.ts@@ -21,10 +21,14 @@ const modelsData = process.env.MODELS_DEV_API_JSON? await Bun.file(process.env.MODELS_DEV_API_JSON).text(): await fetch(`${modelsUrl}/api.json`).then((x) => x.text())await Bun.write(- path.join(dir, "src/provider/models-snapshot.ts"),- `// Auto-generated by build.ts - do not edit\nexport const snapshot = ${modelsData} as const\n`,+ path.join(dir, "src/provider/models-snapshot.js"),+ `// @ts-nocheck\n// Auto-generated by build.ts - do not edit\nexport const snapshot = ${modelsData}\n`,)-console.log("Generated models-snapshot.ts")+await Bun.write(+ path.join(dir, "src/provider/models-snapshot.d.ts"),+ `// Auto-generated by build.ts - do not edit\nexport declare const snapshot: Record<string, unknown>\n`,+)+console.log("Generated models-snapshot.js")// Load migrations from migration directoriesconst migrationDirs = (diff --git a/packages/opencode/src/provider/models.ts b/packages/opencode/src/provider/models.tsindex bae33178467..30901ea74f0 100644--- a/packages/opencode/src/provider/models.ts+++ b/packages/opencode/src/provider/models.ts@@ -89,7 +89,7 @@ export namespace ModelsDev {const result = await Filesystem.readJson(Flag.OPENCODE_MODELS_PATH ?? filepath).catch(() => {})if (result) return result// @ts-ignore- const snapshot = await import("./models-snapshot")+ const snapshot = await import("./models-snapshot.js").then((m) => m.snapshot as Record<string, unknown>).catch(() => undefined)if (snapshot) return snapshot