Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#307 Assign type of any to asMap and asMappedResults #308

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions N/query.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,10 @@ export interface Condition {
readonly component: Component;
}

export type QueryResultMap = { [fieldId: string]: string | boolean | number | null }
export type LowercaseKeys<T> = {
[K in keyof T as Lowercase<K & string>]: T[K];
};

/**
* Set of results returned by the query.
*/
Expand Down Expand Up @@ -637,8 +640,7 @@ export interface ResultSet {
* A mapped result is a JavaScript object with key-value pairs.
* In this object, the key is either the field ID or the alias that was used for the corresponding query.Column object.
*/
asMappedResults(): Array<QueryResultMap>;
asMappedResults<QueryResultMap>(): Array<QueryResultMap>;
asMappedResults<T extends LowercaseKeys<T>>(): LowercaseKeys<T>[];
}

/** Corresponds to a single row of the ResultSet. */
Expand All @@ -661,8 +663,7 @@ export interface Result {
* A mapped result is a JavaScript object with key-value pairs.
* In this object, the key is either the field ID or the alias that was used for the corresponding query.Column object.
*/
asMap(): QueryResultMap;
asMap<QueryResultMap>(): QueryResultMap
asMap<T extends LowercaseKeys<T>>(): LowercaseKeys<T>;
}

/**
Expand Down