Skip to content

Commit 6a0b647

Browse files
committed
fix: remove import of type from superagent
1 parent 4b1fde6 commit 6a0b647

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

packages/superagent-wrapper/src/request.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ type SuperagentLike<Req> = {
5151
[K in h.Method]: (url: string) => Req;
5252
};
5353

54-
type Response = {
54+
export type Response = {
5555
body: unknown;
5656
status: number;
5757
};
5858

59-
interface SuperagentRequest<Res extends Response> extends Promise<Res> {
59+
export interface SuperagentRequest<Res extends Response> extends Promise<Res> {
6060
ok(callback: (response: Res) => boolean): this;
6161
query(params: Record<string, string | string[]>): this;
6262
set(name: string, value: string): this;

packages/superagent-wrapper/src/routes.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
import * as h from '@api-ts/io-ts-http';
2-
import type { SuperAgentRequest } from 'superagent';
2+
import type { SuperagentRequest, Response } from './request';
33

44
import { requestForRoute, BoundRequestFactory, RequestFactory } from './request';
55

6-
export type ApiClient<Req extends SuperAgentRequest, Spec extends h.ApiSpec> = {
6+
export type ApiClient<
7+
Req extends SuperagentRequest<Response>,
8+
Spec extends h.ApiSpec,
9+
> = {
710
[A in keyof Spec]: {
811
[B in keyof Spec[A] & h.Method]: BoundRequestFactory<Req, NonNullable<Spec[A][B]>>;
912
};
1013
};
1114

12-
export const buildApiClient = <Req extends SuperAgentRequest, Spec extends h.ApiSpec>(
15+
export const buildApiClient = <
16+
Req extends SuperagentRequest<Response>,
17+
Spec extends h.ApiSpec,
18+
>(
1319
requestFactory: RequestFactory<Req>,
1420
spec: Spec,
1521
): ApiClient<Req, Spec> => {

0 commit comments

Comments
 (0)