From a60861c960bf3d24af9b2784b5b333855c968731 Mon Sep 17 00:00:00 2001 From: Ben Holmes Date: Wed, 6 Mar 2024 08:30:45 -0500 Subject: [PATCH] fix: move db ambient types to separate module (#10340) * fix: move ambient types to separate modue * chore: changeset --- .changeset/dry-pants-act.md | 5 +++++ packages/db/index.d.ts | 6 ++---- packages/db/src/index.ts | 1 - packages/db/virtual.d.ts | 9 +++++++++ 4 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 .changeset/dry-pants-act.md create mode 100644 packages/db/virtual.d.ts 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; +}