Skip to content

[BUG] TS Type Error - connection.connection property not typed #459

@BrendanC23

Description

@BrendanC23

Describe your system

  • odbc Package Version: 2.4.9

Describe the bug
The Connection class has a connected getter method:

get connected() {
if (!this.odbcConnection)
{
return false;
}
return this.odbcConnection.connected;
}

However, this is not included in odbc.d.ts:

node-odbc/lib/odbc.d.ts

Lines 84 to 146 in d52c262

class Connection {
////////////////////////////////////////////////////////////////////////////
// Callbacks ///////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
query<T>(sql: string, callback: (error: NodeOdbcError, result: Result<T>) => undefined): undefined;
query<T>(sql: string, parameters: Array<number|string>, callback: (error: NodeOdbcError, result: Result<T> | Cursor) => undefined): undefined;
query<T, O extends QueryOptions>(sql: string, options: O, callback: (error: NodeOdbcError, result: O extends CursorQueryOptions ? Cursor : Result<T>) => undefined): undefined;
query<T, O extends QueryOptions>(sql: string, parameters: Array<number|string>, options: O, callback: (error: NodeOdbcError, result: O extends CursorQueryOptions ? Cursor : Result<T>) => undefined): undefined;
callProcedure<T>(catalog: string|null, schema: string|null, name: string, callback: (error: NodeOdbcError, result: Result<T>) => undefined): undefined;
callProcedure<T>(catalog: string|null, schema: string|null, name: string, parameters: Array<number|string>, callback: (error: NodeOdbcError, result: Result<T>) => undefined): undefined;
createStatement(callback: (error: NodeOdbcError, statement: Statement) => undefined): undefined;
primaryKeys<T>(catalog: string|null, schema: string|null, table: string|null, callback: (error: NodeOdbcError, result: Result<T>) => undefined): undefined;
foreignKeys<T>(pkCatalog: string|null, pkSchema: string|null, pkTable: string|null, fkCatalog: string|null, fkSchema: string|null, fkTable: string|null, callback: (error: NodeOdbcError, result: Result<T>) => undefined): undefined;
tables<T>(catalog: string|null, schema: string|null, table: string|null, type: string|null, callback: (error: NodeOdbcError, result: Result<T>) => undefined): undefined;
columns<T>(catalog: string|null, schema: string|null, table: string|null, column: string|null, callback: (error: NodeOdbcError, result: Result<T>) => undefined): undefined;
setIsolationLevel(level: number, callback: (error: NodeOdbcError) => undefined): undefined;
beginTransaction(callback: (error: NodeOdbcError) => undefined): undefined;
commit(callback: (error: NodeOdbcError) => undefined): undefined;
rollback(callback: (error: NodeOdbcError) => undefined): undefined;
close(callback: (error: NodeOdbcError) => undefined): undefined;
////////////////////////////////////////////////////////////////////////////
// Promises ////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
query<T>(sql: string): Promise<Result<T>>;
query<T>(sql: string, parameters: Array<number|string>): Promise<Result<T>>;
query<T, O extends QueryOptions>(sql: string, options: O): O extends CursorQueryOptions ? Promise<Cursor> : Promise<Result<T>>;
query<T, O extends QueryOptions>(sql: string, parameters: Array<number|string>, options: O): O extends CursorQueryOptions ? Promise<Cursor> : Promise<Result<T>>;
callProcedure<T>(catalog: string|null, schema: string|null, name: string, parameters?: Array<number|string>): Promise<Result<T>>;
createStatement(): Promise<Statement>;
primaryKeys<T>(catalog: string|null, schema: string|null, table: string|null): Promise<Result<T>>;
foreignKeys<T>(pkCatalog: string|null, pkSchema: string|null, pkTable: string|null, fkCatalog: string|null, fkSchema: string|null, fkTable: string|null): Promise<Result<T>>;
tables<T>(catalog: string|null, schema: string|null, table: string|null, type: string|null): Promise<Result<T>>;
columns<T>(catalog: string|null, schema: string|null, table: string|null, column: string|null): Promise<Result<T>>;
setIsolationLevel(level: number): Promise<void>;
beginTransaction(): Promise<void>;
commit(): Promise<void>;
rollback(): Promise<void>;
close(): Promise<void>;
}

Expected behavior
The TypeScript types should fully list the available methods.

To Reproduce
The following code produces a TypeScript error:

const connection = await odbc.connect(connectionString);
const isConnected = connection.connected; // Property 'connected' does not exist on type 'Connection'.ts(2339)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions