Open MarkHerhold opened 4 years ago
Thanks @MarkHerhold! Will review this soon.
Unfortunantly, the options object is completely wrong still. I'll have to take another look at it.
@jeremydaly Ok I figured out what you were doing with options and made some changes!
BTW, something I noticed - it's probably not a good idea to mutate global objects in this lib because you don't document the side effects and users don't expect it. IMO, it's best to leave that up to the user.
Having typings support will be a nice improvement.
It would be interesting to have a generic parameter for iDataAPIQueryResult
and use with query
so you can do things like this without having to cast:
const result = await db.query<RecordType>('SELECT * from records');
const record = result.records[0];
Something like:
export interface iDataAPIClient {
query<T>(sql: string, params?: [] | unknown): Promise<iDataAPIQueryResult<T>>;
query<T>(obj: { sql: string; parameters: [] | unknown; database: string; hydrateColumnNames?: boolean }): Promise<iDataAPIQueryResult<T>>;
}
export interface iDataAPIQueryResult<T> {
records: Array<T>;
}
@rraziel good idea, will give it a shot 👍
Anything I can do to help out on this one, @jeremydaly? The type definitions on DefinitelyTyped have what I think might be an errant type reference:
// This is added because aws-sdk depends on @types/node
/// <reference types="node" />
This is causing errors in our Reactive Native app because RN uses browser timers and referencing the node types redefines the timer functions, causing TSC errors b/c we're using number
types when it now wants NodeJS.Timeout
types.
Hi, any chances that will be merged soon?
First pass at TS types from #2