Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve types #75

Merged
merged 3 commits into from
May 21, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2032,7 +2032,15 @@ declare type Sqlite3Static = {
installVfs: (obj: {
io?: {
struct: sqlite3_io_methods;
methods: Omit<sqlite3_io_methods, 'iVersion'>;
methods: { [K in keyof sqlite3_io_methods as K extends `x${string}` ? K : never]?: sqlite3_io_methods[K] };
Copy link
Contributor Author

@qwtel qwtel May 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to pick all properties that start with x (e.g. xRead, xWrite, etc) rather than omit known static properties, specially for sqlite_vfs below which has a lot more of them.

applyArgcCheck?: boolean;
};
vfs?: {
struct: sqlite3_vfs;
methods: { [K in keyof sqlite3_vfs as K extends `x${string}` ? K : never]?: sqlite3_vfs[K] };
applyArgcCheck?: boolean;
name?: string;
asDefault?: boolean;
};
}) => Sqlite3Static['vfs'];
};
Expand Down Expand Up @@ -2792,7 +2800,7 @@ declare type WASM_API = {
poke32: (addr: WasmPointer, value: number) => WASM_API;

/** Equivalent to poke(X,Y,'i64') */
poke64: (addr: WasmPointer, value: number) => WASM_API;
poke64: (addr: WasmPointer, value: number|bigint) => WASM_API;

/** Equivalent to poke(X,Y,'f32') */
poke32f: (addr: WasmPointer, value: number) => WASM_API;
Expand Down Expand Up @@ -5729,7 +5737,7 @@ declare type CAPI = {
*
* See https://www.sqlite.org/c3ref/vfs_find.html
*/
sqlite3_vfs_find: (vfsName: string) => sqlite3_vfs;
sqlite3_vfs_find: (vfsName: string|null) => WasmPointer;
Copy link
Contributor Author

@qwtel qwtel May 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find doesn't return the vfs directly, needs a separate new sqlite_vfs(ptr) call.
Also, it's allowed to pass null to get the default vfs


/**
* Register a new VFS. Becomes the default if the makeDflt parameter is set.
Expand Down