diff --git a/.changeset/dry-pants-act.md b/.changeset/dry-pants-act.md new file mode 100644 index 0000000000..a6279685ab --- /dev/null +++ b/.changeset/dry-pants-act.md @@ -0,0 +1,5 @@ +--- +"@astrojs/db": patch +--- + +Ensure `astro:db` types exist in your `db/config.ts` before running type generation. diff --git a/packages/db/index.d.ts b/packages/db/index.d.ts index 81af4fb43c..7c0e055b2c 100644 --- a/packages/db/index.d.ts +++ b/packages/db/index.d.ts @@ -1,5 +1,3 @@ -export { default, cli } from './dist/index.js'; +import './virtual.js'; -declare module 'astro:db' { - export { defineTable, defineDB, column, sql, NOW, TRUE, FALSE } from './dist/index.js'; -} +export { default, cli } from './dist/index.js'; diff --git a/packages/db/src/index.ts b/packages/db/src/index.ts index 0073f2b33c..a275433764 100644 --- a/packages/db/src/index.ts +++ b/packages/db/src/index.ts @@ -1,4 +1,3 @@ export type { ResolvedCollectionConfig, TableConfig } from './core/types.js'; export { cli } from './core/cli/index.js'; export { integration as default } from './core/integration/index.js'; -export { sql, NOW, TRUE, FALSE, defineDB, defineTable, column } from './runtime/config.js'; diff --git a/packages/db/virtual.d.ts b/packages/db/virtual.d.ts new file mode 100644 index 0000000000..57398d6e6f --- /dev/null +++ b/packages/db/virtual.d.ts @@ -0,0 +1,9 @@ +declare module 'astro:db' { + export const sql: typeof import('./dist/runtime/config.js').sql; + export const NOW: typeof import('./dist/runtime/config.js').NOW; + export const TRUE: typeof import('./dist/runtime/config.js').TRUE; + export const FALSE: typeof import('./dist/runtime/config.js').FALSE; + export const column: typeof import('./dist/runtime/config.js').column; + export const defineDB: typeof import('./dist/runtime/config.js').defineDB; + export const defineTable: typeof import('./dist/runtime/config.js').defineTable; +}