Skip to content

Commit 50f6aa3

Browse files
authored
fix(opencode): skip typechecking generated models snapshot (anomalyco#19018)
1 parent 0dcdf5f commit 50f6aa3

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

packages/opencode/script/build.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@ const modelsData = process.env.MODELS_DEV_API_JSON
2121
? await Bun.file(process.env.MODELS_DEV_API_JSON).text()
2222
: await fetch(`${modelsUrl}/api.json`).then((x) => x.text())
2323
await Bun.write(
24-
path.join(dir, "src/provider/models-snapshot.ts"),
25-
`// Auto-generated by build.ts - do not edit\nexport const snapshot = ${modelsData} as const\n`,
24+
path.join(dir, "src/provider/models-snapshot.js"),
25+
`// @ts-nocheck\n// Auto-generated by build.ts - do not edit\nexport const snapshot = ${modelsData}\n`,
2626
)
27-
console.log("Generated models-snapshot.ts")
27+
await Bun.write(
28+
path.join(dir, "src/provider/models-snapshot.d.ts"),
29+
`// Auto-generated by build.ts - do not edit\nexport declare const snapshot: Record<string, unknown>\n`,
30+
)
31+
console.log("Generated models-snapshot.js")
2832

2933
// Load migrations from migration directories
3034
const migrationDirs = (

packages/opencode/src/provider/models.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export namespace ModelsDev {
8989
const result = await Filesystem.readJson(Flag.OPENCODE_MODELS_PATH ?? filepath).catch(() => {})
9090
if (result) return result
9191
// @ts-ignore
92-
const snapshot = await import("./models-snapshot")
92+
const snapshot = await import("./models-snapshot.js")
9393
.then((m) => m.snapshot as Record<string, unknown>)
9494
.catch(() => undefined)
9595
if (snapshot) return snapshot

0 commit comments

Comments
 (0)