From 46da1abba498b41612fcba9804252471772235fd Mon Sep 17 00:00:00 2001 From: Steve Cruz Date: Mon, 13 Mar 2023 13:21:04 -0700 Subject: [PATCH] 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 --- lib/sqlite3.d.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/sqlite3.d.ts b/lib/sqlite3.d.ts index b27b0cf51..15e66230e 100644 --- a/lib/sqlite3.d.ts +++ b/lib/sqlite3.d.ts @@ -80,16 +80,16 @@ export class Statement extends events.EventEmitter { run(params: any, callback?: (this: RunResult, err: Error | null) => void): this; run(...params: any[]): this; - get(callback?: (err: Error | null, row?: any) => void): this; - get(params: any, callback?: (this: RunResult, err: Error | null, row?: any) => void): this; + get(callback?: (err: Error | null, row?: T) => void): this; + get(params: any, callback?: (this: RunResult, err: Error | null, row?: T) => void): this; get(...params: any[]): this; - all(callback?: (err: Error | null, rows: any[]) => void): this; - all(params: any, callback?: (this: RunResult, err: Error | null, rows: any[]) => void): this; + all(callback?: (err: Error | null, rows: T[]) => void): this; + all(params: any, callback?: (this: RunResult, err: Error | null, rows: T[]) => void): this; all(...params: any[]): this; - each(callback?: (err: Error | null, row: any) => void, complete?: (err: Error | null, count: number) => void): this; - each(params: any, callback?: (this: RunResult, err: Error | null, row: any) => void, complete?: (err: Error | null, count: number) => void): this; + each(callback?: (err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this; + each(params: any, callback?: (this: RunResult, err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this; each(...params: any[]): this; } @@ -103,16 +103,16 @@ export class Database extends events.EventEmitter { run(sql: string, params: any, callback?: (this: RunResult, err: Error | null) => void): this; run(sql: string, ...params: any[]): this; - get(sql: string, callback?: (this: Statement, err: Error | null, row: any) => void): this; - get(sql: string, params: any, callback?: (this: Statement, err: Error | null, row: any) => void): this; + get(sql: string, callback?: (this: Statement, err: Error | null, row: T) => void): this; + get(sql: string, params: any, callback?: (this: Statement, err: Error | null, row: T) => void): this; get(sql: string, ...params: any[]): this; - all(sql: string, callback?: (this: Statement, err: Error | null, rows: any[]) => void): this; - all(sql: string, params: any, callback?: (this: Statement, err: Error | null, rows: any[]) => void): this; + all(sql: string, callback?: (this: Statement, err: Error | null, rows: T[]) => void): this; + all(sql: string, params: any, callback?: (this: Statement, err: Error | null, rows: T[]) => void): this; all(sql: string, ...params: any[]): this; - each(sql: string, callback?: (this: Statement, err: Error | null, row: any) => void, complete?: (err: Error | null, count: number) => void): this; - each(sql: string, params: any, callback?: (this: Statement, err: Error | null, row: any) => void, complete?: (err: Error | null, count: number) => void): this; + each(sql: string, callback?: (this: Statement, err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this; + each(sql: string, params: any, callback?: (this: Statement, err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this; each(sql: string, ...params: any[]): this; exec(sql: string, callback?: (this: Statement, err: Error | null) => void): this;