Skip to content

Commit 5ef82ee

Browse files
tantamanjbaiter
authored andcommitted
fix index.d.ts to actually compile
1 parent d6a1f02 commit 5ef82ee

File tree

1 file changed

+45
-44
lines changed

1 file changed

+45
-44
lines changed

index.d.ts

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
declare module "@sqlite.org/sqlite-wasm" {
1+
declare module '@sqlite.org/sqlite-wasm' {
22
type InitOptions = {
33
print: (...msg: any[]) => void;
44
printErr: (...msg: any[]) => void;
55
};
66

7-
declare type PreparedStatement = {
7+
type PreparedStatement = {
88
db: DatabaseApi;
99
bind(value: any): PreparedStatement;
1010
bind(idx: number, value: any): PreparedStatement;
@@ -16,41 +16,41 @@ declare module "@sqlite.org/sqlite-wasm" {
1616
stepFinalize(): boolean;
1717

1818
// TODO
19-
columnCount: any;
20-
parameterCount: any;
21-
clearBindings: any;
22-
reset: any;
23-
step: any;
24-
stepReset: any;
25-
getInt: any;
26-
getFloat: any;
27-
getString: any;
28-
getBlob: any;
19+
columnCount(): number;
20+
parameterCount(): number;
21+
clearBindings(): any;
22+
reset(): any;
23+
step(): any;
24+
stepReset(): any;
25+
getInt(c: number): number;
26+
getFloat(c: number): number;
27+
getString(c: number): string;
28+
getBlob(c: number): Uint8Array;
2929
getJSON: any;
30-
getColumnName: any;
31-
getColumnNames: any;
30+
getColumnName(c: number): string;
31+
getColumnNames(): string[];
3232
getParamIndex: any;
3333
pointer: number;
34-
}
34+
};
3535

36-
declare type ExecOptions = {
37-
sql?: string,
38-
bind?: Array<string | number>
36+
type ExecOptions = {
37+
sql?: string;
38+
bind?: Array<string | number>;
3939
saveSql?: Array<any>;
40-
returnValue?: "this" | "resultRows";
41-
callback?: (result: any, stmt: PreparedStatement) => void
42-
}
40+
returnValue?: 'this' | 'resultRows';
41+
callback?: (result: any, stmt: PreparedStatement) => void;
42+
};
4343

4444
type ExecThisOptions = ExecOptions & {
45-
returnValue?: "this" | undefined;
46-
}
45+
returnValue?: 'this' | undefined;
46+
};
4747

4848
type ExecResultRowsOptions = ExecOptions & {
49-
returnValue: "resultRows";
50-
rowMode?: 'array' | 'object' | 'stmt'
51-
}
49+
returnValue: 'resultRows';
50+
rowMode?: 'array' | 'object' | 'stmt';
51+
};
5252

53-
declare type DatabaseApi = {
53+
class DatabaseApi {
5454
filename: string;
5555
pointer: number;
5656
exec(input: string, opts?: ExecThisOptions): DatabaseApi;
@@ -82,32 +82,31 @@ declare module "@sqlite.org/sqlite-wasm" {
8282
transaction: Function;
8383
savepoint: Function;
8484
checkRc: Function;
85-
};
85+
}
8686

87-
export declare class JsStorageDb implements DatabaseApi {
87+
export class JsStorageDb extends DatabaseApi {
8888
constructor(mode: 'local' | 'session');
8989
storageSize(): number;
9090
clearStorage(): void;
91-
};
91+
}
9292

93-
export declare class OpfsDatabase implements DatabaseApi {
93+
export class OpfsDatabase extends DatabaseApi {
9494
constructor(filename: string);
95-
};
95+
}
96+
97+
export type Flags = 'c' | 'w' | 'r' | 't';
9698

97-
export type Flags = "c" | "w" | "r" | "t";
98-
export declare class Database implements DatabaseApi {
99-
constructor(options: {
100-
filename: string, flags: string, vfs?: any
101-
});
99+
export class Database extends DatabaseApi {
100+
constructor(options: { filename: string; flags: string; vfs?: any });
102101
constructor(filename: string, flags: string, vfs?: any);
103-
};
102+
}
104103

105-
declare class WasmAllocError extends Error {
104+
class WasmAllocError extends Error {
106105
constructor(message: string);
107106
toss: any;
108107
}
109108

110-
declare class SQLite3Error extends Error {
109+
class SQLite3Error extends Error {
111110
constructor(message: string);
112111
}
113112

@@ -180,10 +179,12 @@ declare module "@sqlite.org/sqlite-wasm" {
180179
};
181180
};
182181

183-
export default function sqlite3InitModule(opts: InitOptions): Promise<Sqlite3Static>;
182+
export default function sqlite3InitModule(
183+
opts: InitOptions,
184+
): Promise<Sqlite3Static>;
184185

185186
// generated by Object.keys(sqlite3.capi).map(k => `${k}: any;`).join('\n')
186-
declare type CAPI = {
187+
type CAPI = {
187188
sqlite3_bind_blob: any;
188189
sqlite3_bind_text: any;
189190
sqlite3_create_function_v2: any;
@@ -812,7 +813,7 @@ declare module "@sqlite.org/sqlite-wasm" {
812813
};
813814

814815
// generated by console.log(Object.keys(sqlite3.wasm).map(t => ` ${t}: any;`).join('\n'))
815-
declare type WASM_API = {
816+
type WASM_API = {
816817
ptrSizeof: any;
817818
ptrIR: any;
818819
bigIntEnabled: any;
@@ -887,4 +888,4 @@ declare module "@sqlite.org/sqlite-wasm" {
887888
sqlite3_wasm_vfs_unlink: any;
888889
ctype: any;
889890
};
890-
};
891+
}

0 commit comments

Comments
 (0)