diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts index 16737046ee..f29e3f9cd3 100644 --- a/packages/bun-types/bun.d.ts +++ b/packages/bun-types/bun.d.ts @@ -1384,14 +1384,14 @@ declare module "bun" { * Database password for authentication * @default "" */ - password?: string | (() => Promise) | undefined; + password?: string | (() => MaybePromise) | undefined; /** * Database password for authentication (alias for password) * @deprecated Prefer {@link password} * @default "" */ - pass?: string | (() => Promise) | undefined; + pass?: string | (() => MaybePromise) | undefined; /** * Name of the database to connect to diff --git a/packages/bun-types/deprecated.d.ts b/packages/bun-types/deprecated.d.ts index 1534879311..4fa3294a26 100644 --- a/packages/bun-types/deprecated.d.ts +++ b/packages/bun-types/deprecated.d.ts @@ -14,16 +14,16 @@ declare module "bun" { ): void; } - /** @deprecated Use {@link SQL.Query} */ + /** @deprecated Use {@link SQL.Query Bun.SQL.Query} */ type SQLQuery = SQL.Query; - /** @deprecated Use {@link SQL.TransactionContextCallback} */ + /** @deprecated Use {@link SQL.TransactionContextCallback Bun.SQL.TransactionContextCallback} */ type SQLTransactionContextCallback = SQL.TransactionContextCallback; - /** @deprecated Use {@link SQL.SavepointContextCallback} */ + /** @deprecated Use {@link SQL.SavepointContextCallback Bun.SQL.SavepointContextCallback} */ type SQLSavepointContextCallback = SQL.SavepointContextCallback; - /** @deprecated Use {@link SQL.Options} */ + /** @deprecated Use {@link SQL.Options Bun.SQL.Options} */ type SQLOptions = SQL.Options; /** diff --git a/src/js/bun/sql.ts b/src/js/bun/sql.ts index de6f753f84..84aa23211e 100644 --- a/src/js/bun/sql.ts +++ b/src/js/bun/sql.ts @@ -1339,7 +1339,7 @@ function decodeIfValid(value) { } return null; } -function loadOptions(o) { +function loadOptions(o: Bun.SQL.Options) { var hostname, port, username, diff --git a/test/integration/bun-types/fixture/sql.ts b/test/integration/bun-types/fixture/sql.ts index 43be5988c0..20aab93e96 100644 --- a/test/integration/bun-types/fixture/sql.ts +++ b/test/integration/bun-types/fixture/sql.ts @@ -200,6 +200,15 @@ expectType(await queryNum.execute()).is(); expectType(await queryNum.raw()).is(); expectType(await queryNum.values()).is(); +expectType({ + password: () => "hey", + pass: async () => "hey", +}); + +expectType({ + password: "hey", +}); + expectType(sql({ name: "Alice", email: "alice@example.com" })).is< Bun.SQL.Helper<{ name: string;