fix(bgm): pass options arg to buildStart in unit test

Vite 8 (rolldown) changed buildStart to take (this, options), so the
test's one-arg call failed typecheck. Add an ambient declaration for the
fixture's virtual bgm modules so its entry typechecks in the editor.
This commit is contained in:
2026-08-09 22:17:19 +08:00
parent 87e6eee9fe
commit b4cdcdeb42
2 changed files with 21 additions and 1 deletions
@@ -0,0 +1,18 @@
/// <reference types="vite/client" />
/**
* Ambient types for the virtual `bgm` modules served by the bgm vite plugin,
* so the fixture's entry typechecks in the editor (the plugin provides them at
* build time). Mirrors `apps/web/src/vite-env.d.ts`.
*/
declare module 'virtual:bgm/packages' {
import type { SerializedPackage } from '@tts/bgm';
const packages: SerializedPackage[];
export default packages;
}
declare module 'virtual:bgm/package/*' {
import type { SerializedPackage } from '@tts/bgm';
const pkg: SerializedPackage;
export default pkg;
}
+3 -1
View File
@@ -80,7 +80,9 @@ describe('bgm vite plugin', () => {
const plugin = bgm({ root: gamesRoot }); const plugin = bgm({ root: gamesRoot });
const watched: string[] = []; const watched: string[] = [];
const context = { addWatchFile: (file: string) => watched.push(file) }; const context = { addWatchFile: (file: string) => watched.push(file) };
(plugin.buildStart as Callable<typeof plugin.buildStart>).call(context); // Vite 8 (rolldown) `buildStart` takes `(this, options)`; the plugin ignores
// the options, so pass a placeholder.
(plugin.buildStart as Callable<typeof plugin.buildStart>).call(context, {} as never);
// Every def file (real + virtual code blocks) is watched so edits // Every def file (real + virtual code blocks) is watched so edits
// trigger a re-collect. // trigger a re-collect.