fix(opencode): skip typechecking generated models snapshot (#19018)

pull/19038/head^2
Kit Langton 2026-03-24 19:11:45 -04:00 committed by GitHub
parent 0dcdf5f529
commit 50f6aa3763
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View File

@ -21,10 +21,14 @@ const modelsData = process.env.MODELS_DEV_API_JSON
? await Bun.file(process.env.MODELS_DEV_API_JSON).text() ? await Bun.file(process.env.MODELS_DEV_API_JSON).text()
: await fetch(`${modelsUrl}/api.json`).then((x) => x.text()) : await fetch(`${modelsUrl}/api.json`).then((x) => x.text())
await Bun.write( await Bun.write(
path.join(dir, "src/provider/models-snapshot.ts"), path.join(dir, "src/provider/models-snapshot.js"),
`// Auto-generated by build.ts - do not edit\nexport const snapshot = ${modelsData} as const\n`, `// @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 directories // Load migrations from migration directories
const migrationDirs = ( const migrationDirs = (

View File

@ -89,7 +89,7 @@ export namespace ModelsDev {
const result = await Filesystem.readJson(Flag.OPENCODE_MODELS_PATH ?? filepath).catch(() => {}) const result = await Filesystem.readJson(Flag.OPENCODE_MODELS_PATH ?? filepath).catch(() => {})
if (result) return result if (result) return result
// @ts-ignore // @ts-ignore
const snapshot = await import("./models-snapshot") const snapshot = await import("./models-snapshot.js")
.then((m) => m.snapshot as Record<string, unknown>) .then((m) => m.snapshot as Record<string, unknown>)
.catch(() => undefined) .catch(() => undefined)
if (snapshot) return snapshot if (snapshot) return snapshot