Skip to content

Commit 46da1ab

Browse files
authored
Added generic type annotations for Statement and Database get/all/each methods callback rows (#1686)
* Change sqlite3.d.ts to add generic type definition support for Statement methods -For get method callback's row -For all method callback's rows -For each method callback's row * Change sqlite3.d.ts to add generic type definition support for Database methods -For get method callback's row -For all method callback's rows -For each method callback's row
1 parent 6a806f8 commit 46da1ab

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

lib/sqlite3.d.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,16 @@ export class Statement extends events.EventEmitter {
8080
run(params: any, callback?: (this: RunResult, err: Error | null) => void): this;
8181
run(...params: any[]): this;
8282

83-
get(callback?: (err: Error | null, row?: any) => void): this;
84-
get(params: any, callback?: (this: RunResult, err: Error | null, row?: any) => void): this;
83+
get<T>(callback?: (err: Error | null, row?: T) => void): this;
84+
get<T>(params: any, callback?: (this: RunResult, err: Error | null, row?: T) => void): this;
8585
get(...params: any[]): this;
8686

87-
all(callback?: (err: Error | null, rows: any[]) => void): this;
88-
all(params: any, callback?: (this: RunResult, err: Error | null, rows: any[]) => void): this;
87+
all<T>(callback?: (err: Error | null, rows: T[]) => void): this;
88+
all<T>(params: any, callback?: (this: RunResult, err: Error | null, rows: T[]) => void): this;
8989
all(...params: any[]): this;
9090

91-
each(callback?: (err: Error | null, row: any) => void, complete?: (err: Error | null, count: number) => void): this;
92-
each(params: any, callback?: (this: RunResult, err: Error | null, row: any) => void, complete?: (err: Error | null, count: number) => void): this;
91+
each<T>(callback?: (err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this;
92+
each<T>(params: any, callback?: (this: RunResult, err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this;
9393
each(...params: any[]): this;
9494
}
9595

@@ -103,16 +103,16 @@ export class Database extends events.EventEmitter {
103103
run(sql: string, params: any, callback?: (this: RunResult, err: Error | null) => void): this;
104104
run(sql: string, ...params: any[]): this;
105105

106-
get(sql: string, callback?: (this: Statement, err: Error | null, row: any) => void): this;
107-
get(sql: string, params: any, callback?: (this: Statement, err: Error | null, row: any) => void): this;
106+
get<T>(sql: string, callback?: (this: Statement, err: Error | null, row: T) => void): this;
107+
get<T>(sql: string, params: any, callback?: (this: Statement, err: Error | null, row: T) => void): this;
108108
get(sql: string, ...params: any[]): this;
109109

110-
all(sql: string, callback?: (this: Statement, err: Error | null, rows: any[]) => void): this;
111-
all(sql: string, params: any, callback?: (this: Statement, err: Error | null, rows: any[]) => void): this;
110+
all<T>(sql: string, callback?: (this: Statement, err: Error | null, rows: T[]) => void): this;
111+
all<T>(sql: string, params: any, callback?: (this: Statement, err: Error | null, rows: T[]) => void): this;
112112
all(sql: string, ...params: any[]): this;
113113

114-
each(sql: string, callback?: (this: Statement, err: Error | null, row: any) => void, complete?: (err: Error | null, count: number) => void): this;
115-
each(sql: string, params: any, callback?: (this: Statement, err: Error | null, row: any) => void, complete?: (err: Error | null, count: number) => void): this;
114+
each<T>(sql: string, callback?: (this: Statement, err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this;
115+
each<T>(sql: string, params: any, callback?: (this: Statement, err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this;
116116
each(sql: string, ...params: any[]): this;
117117

118118
exec(sql: string, callback?: (this: Statement, err: Error | null) => void): this;

0 commit comments

Comments
 (0)