File tree Expand file tree Collapse file tree 5 files changed +12
-17
lines changed
documentation/src/pages/guides/concepts
openapi-code-generator/src/typescript/typescript-fetch
typescript-fetch-runtime/src Expand file tree Collapse file tree 5 files changed +12
-17
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ export class ApiClient {
9595 .build(),
9696 timeout?: number,
9797 opts: RequestInit = {},
98- ): Promise<TypedFetchResponse< Res<202, void> >> {
98+ ): Promise<Res<202, void>> {
9999 ...
100100 }
101101}
Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ export class TypescriptFetchClientBuilder extends TypescriptClientBuilder {
1515 "AbstractFetchClient" ,
1616 "Server" ,
1717 "Res" ,
18- "TypedFetchResponse" ,
1918 "StatusCode2xx" ,
2019 "StatusCode3xx" ,
2120 "StatusCode4xx" ,
@@ -112,7 +111,7 @@ export class TypescriptFetchClientBuilder extends TypescriptClientBuilder {
112111 default : "{}" ,
113112 } ,
114113 ] ,
115- returnType : `TypedFetchResponse< ${ returnType } >` ,
114+ returnType,
116115 body,
117116 } )
118117 }
Original file line number Diff line number Diff line change 11import type { Schema as JoiSchema } from "@hapi/joi"
2- import type { Res , StatusCode , TypedFetchResponse } from "./main"
2+ import type { Res , StatusCode } from "./main"
33
44export function responseValidationFactory (
55 possibleResponses : [ string , JoiSchema ] [ ] ,
@@ -10,9 +10,9 @@ export function responseValidationFactory(
1010
1111 // TODO: avoid any
1212 return async (
13- whenRes : TypedFetchResponse < Res < StatusCode , unknown > > ,
13+ whenRes : Promise < Res < StatusCode , unknown > > ,
1414 // biome-ignore lint/suspicious/noExplicitAny: <explanation>
15- ) : Promise < TypedFetchResponse < any > > => {
15+ ) : Promise < any > => {
1616 const res = await whenRes
1717
1818 return {
Original file line number Diff line number Diff line change @@ -26,15 +26,11 @@ export type StatusCode =
2626 | StatusCode4xx
2727 | StatusCode5xx
2828
29- export type Res < Status extends StatusCode , Type > = {
29+ export interface Res < Status extends StatusCode , JsonBody > extends Response {
3030 status : Status
31- json : ( ) => Promise < Type >
31+ json : ( ) => Promise < JsonBody >
3232}
3333
34- export type TypedFetchResponse < R extends Res < StatusCode , unknown > > = Promise <
35- Omit < Response , "json" | "status" > & R
36- >
37-
3834export type Server < T > = string & { __server__ : T }
3935
4036export interface AbstractFetchClientConfig {
@@ -83,7 +79,7 @@ export abstract class AbstractFetchClient {
8379 url : string ,
8480 opts : RequestInit ,
8581 timeout : number | undefined = this . defaultTimeout ,
86- ) : TypedFetchResponse < R > {
82+ ) : Promise < R > {
8783 // main abort controller that will be returned to the caller
8884 const cancelRequest = new AbortController ( )
8985
@@ -118,7 +114,7 @@ export abstract class AbstractFetchClient {
118114 }
119115 // if not aborted just throw
120116 throw err
121- } ) as TypedFetchResponse < R >
117+ } ) as unknown as R
122118 }
123119
124120 protected _query ( params : QueryParams ) : string {
Original file line number Diff line number Diff line change 11import type { z } from "zod"
2- import type { Res , StatusCode , TypedFetchResponse } from "./main"
2+ import type { Res , StatusCode } from "./main"
33
44export function responseValidationFactory (
55 possibleResponses : [ string , z . ZodTypeAny ] [ ] ,
@@ -10,9 +10,9 @@ export function responseValidationFactory(
1010
1111 // TODO: avoid any
1212 return async (
13- whenRes : TypedFetchResponse < Res < StatusCode , unknown > > ,
13+ whenRes : Promise < Res < StatusCode , unknown > > ,
1414 // biome-ignore lint/suspicious/noExplicitAny: <explanation>
15- ) : Promise < TypedFetchResponse < any > > => {
15+ ) : Promise < any > => {
1616 const res = await whenRes
1717
1818 return {
You can’t perform that action at this time.
0 commit comments