Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
dstaley authored and dependabot[bot] committed Apr 3, 2023
1 parent 91190c2 commit a355cbe
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 4 deletions.
22 changes: 21 additions & 1 deletion src/http/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,26 @@ export default class KintoClientBase {
* JSON.
* @return {Promise<Object, Error>}
*/
async execute<T>(
request: KintoRequest,
options: {
raw: true;
stringify?: boolean;
retry?: number;
query?: { [key: string]: string };
fields?: string[];
}
): Promise<HttpResponse<T>>;
async execute<T>(
request: KintoRequest,
options?: {
raw?: false;
stringify?: boolean;
retry?: number;
query?: { [key: string]: string };
fields?: string[];
}
): Promise<T>;
async execute<T>(
request: KintoRequest,
options: {
Expand Down Expand Up @@ -992,6 +1012,6 @@ export default class KintoClientBase {
{ data: { password } },
{ method: "PUT" }
)
) as Promise<KintoResponse<{ password: string }>>;
);
}
}
2 changes: 1 addition & 1 deletion src/http/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export default class Collection {
raw: true,
retry: this._getRetry(options),
});
return parseInt(headers.get("Total-Records"), 10);
return parseInt(headers.get("Total-Records")!, 10);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD";
export interface KintoRequest {
method?: HttpMethod;
path: string;
headers: HeadersInit;
headers: Record<string, unknown>;
body?: any;
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function filterObject<T extends { [key: string]: any }>(
* @param {Array} list The collection to filter.
* @return {Array}
*/
export function filterObjects<T>(
export function filterObjects<T extends { [key: string]: any }>(
filters: { [key: string]: any },
list: T[]
): T[] {
Expand Down
5 changes: 5 additions & 0 deletions test/http/api_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ describe("KintoClient", () => {
sinon.assert.calledWithMatch(
executeStub,
{ path: `${path}?_sort=-last_modified`, headers: {} },
//@ts-ignore Limitation of the Parameters type for overloaded functions
{ raw: true }
);
});
Expand All @@ -765,6 +766,7 @@ describe("KintoClient", () => {
sinon.assert.calledWithMatch(
executeStub,
{ path: `${path}?_sort=title`, headers: {} },
//@ts-ignore Limitation of the Parameters type for overloaded functions
{ raw: true }
);
});
Expand Down Expand Up @@ -839,6 +841,7 @@ describe("KintoClient", () => {
sinon.assert.calledWithMatch(
executeStub,
{ path: `${path}?${expectedQS}`, headers: {} },
//@ts-ignore Limitation of the Parameters type for overloaded functions
{ raw: true }
);
});
Expand All @@ -850,6 +853,7 @@ describe("KintoClient", () => {
sinon.assert.calledWithMatch(
executeStub,
{ path: `${path}?${expectedQS}`, headers: {} },
//@ts-ignore Limitation of the Parameters type for overloaded functions
{ raw: true }
);
});
Expand All @@ -874,6 +878,7 @@ describe("KintoClient", () => {
sinon.assert.calledWithMatch(
executeStub,
{ path: `${path}?${expectedQS}`, headers: {} },
//@ts-ignore Limitation of the Parameters type for overloaded functions
{ raw: true }
);
});
Expand Down
2 changes: 2 additions & 0 deletions test/http/bucket_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ describe("Bucket", () => {
sinon.assert.calledWithMatch(
executeStub,
{ method: "HEAD", path: "/buckets/blog/collections", headers: {} },
//@ts-ignore Limitation of the Parameters type for overloaded functions
{ raw: true }
);
});
Expand Down Expand Up @@ -558,6 +559,7 @@ describe("Bucket", () => {
sinon.assert.calledWithMatch(
executeStub,
{ method: "HEAD", path: "/buckets/blog/groups", headers: {} },
//@ts-ignore Limitation of the Parameters type for overloaded functions
{ raw: true }
);
});
Expand Down
2 changes: 2 additions & 0 deletions test/http/collection_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe("HTTP Collection", () => {
path: "/buckets/blog/collections/posts/records",
headers: {},
},
//@ts-ignore Limitation of the Parameters type for overloaded functions
{ raw: true }
);
});
Expand Down Expand Up @@ -705,6 +706,7 @@ describe("HTTP Collection", () => {
path: "/buckets/blog/collections/posts/records",
headers: {},
},
//@ts-ignore Limitation of the Parameters type for overloaded functions
{ raw: true }
);
});
Expand Down

0 comments on commit a355cbe

Please sign in to comment.