Skip to content

Commit 03fc278

Browse files
refactor: merge ambient augmentation
1 parent e5b1459 commit 03fc278

File tree

2 files changed

+40
-42
lines changed

2 files changed

+40
-42
lines changed

packages/sql-sqlite-react-native/src/SqliteClient.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,46 @@ import * as Scope from "effect/Scope"
1919

2020
const ATTR_DB_SYSTEM_NAME = "db.system.name"
2121

22+
/**
23+
* Temporary ambient augmentation for `@op-engineering/op-sqlite`.
24+
*
25+
* Why this file exists
26+
* - Under TypeScript `moduleResolution: "NodeNext"`, value exports that come through
27+
* `export * from './functions'` do not show up in the public type definitions unless
28+
* that subpath is explicitly listed in the package `exports` map.
29+
* - In `@op-engineering/[email protected]`, this means `open` (and friends) are
30+
* available at runtime but are not visible to the type system when doing
31+
* `import * as Sqlite from '@op-engineering/op-sqlite'`.
32+
* - Our code calls `Sqlite.open(...)`, which triggers TS2339/TS2305 without this
33+
* augmentation when using NodeNext.
34+
*
35+
* What this does
36+
* - Minimally augments the module to surface the `open` function and a narrow `OPDB`
37+
* shape that covers only what we use here (close/executeSync/executeAsync).
38+
* - This merges with the library’s existing types; it does not replace them.
39+
*
40+
* Removal plan
41+
* - TODO: Remove this file once upstream publishes a fix that explicitly re‑exports
42+
* these functions in the types entry (see tracking PR below). At that point,
43+
* `Sqlite.open` should type‑check without any local augmentation.
44+
*
45+
* More details
46+
* - Upstream PR: https://github.com/OP-Engineering/op-sqlite/pull/324
47+
*/
48+
declare module "@op-engineering/op-sqlite" {
49+
export type OPDB = {
50+
close(): void
51+
executeSync(query: string, params?: Array<unknown>): { rows?: Array<unknown> }
52+
executeAsync(query: string, params?: Array<unknown>): Promise<{ rows?: Array<unknown> }>
53+
}
54+
55+
export function open(options: {
56+
name: string
57+
location?: string
58+
encryptionKey?: string
59+
}): OPDB
60+
}
61+
2262
/**
2363
* @category type ids
2464
* @since 1.0.0

packages/sql-sqlite-react-native/src/op-sqlite-augmentation.d.ts

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)