fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(clients): preserve beforeRequest typing for fetch, next, ky, angular)

+42 -14
+8 -2
packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts
··· 95 95 return { opts, req, url }; 96 96 }; 97 97 98 - const beforeRequest = async (options: RequestOptions) => { 98 + const beforeRequest = async < 99 + TData = unknown, 100 + TResponseStyle extends ResponseStyle = 'fields', 101 + ThrowOnError extends boolean = boolean, 102 + Url extends string = string, 103 + >( 104 + options: RequestOptions<TData, TResponseStyle, ThrowOnError, Url>, 105 + ) => { 99 106 const { opts, req, url } = requestOptions(options); 100 107 101 108 if (opts.security) { ··· 113 120 }; 114 121 115 122 const request: Client['request'] = async (options) => { 116 - // @ts-expect-error 117 123 const { opts, req: initialReq } = await beforeRequest(options); 118 124 119 125 let req = initialReq;
+12 -4
packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts
··· 29 29 30 30 const interceptors = createInterceptors<Request, Response, unknown, ResolvedRequestOptions>(); 31 31 32 - const beforeRequest = async (options: RequestOptions) => { 32 + const beforeRequest = async < 33 + TData = unknown, 34 + TResponseStyle extends 'data' | 'fields' = 'fields', 35 + ThrowOnError extends boolean = boolean, 36 + Url extends string = string, 37 + >( 38 + options: RequestOptions<TData, TResponseStyle, ThrowOnError, Url>, 39 + ) => { 33 40 const opts = { 34 41 ..._config, 35 42 ...options, ··· 58 65 opts.headers.delete('Content-Type'); 59 66 } 60 67 61 - const url = buildUrl(opts); 68 + const resolvedOpts = opts as typeof opts & 69 + ResolvedRequestOptions<TResponseStyle, ThrowOnError, Url>; 70 + const url = buildUrl(resolvedOpts); 62 71 63 - return { opts, url }; 72 + return { opts: resolvedOpts, url }; 64 73 }; 65 74 66 75 const request: Client['request'] = async (options) => { 67 - // @ts-expect-error 68 76 const { opts, url } = await beforeRequest(options); 69 77 const requestInit: ReqInit = { 70 78 redirect: 'follow',
+12 -4
packages/openapi-ts/src/plugins/@hey-api/client-ky/bundle/client.ts
··· 28 28 29 29 const interceptors = createInterceptors<Request, Response, unknown, ResolvedRequestOptions>(); 30 30 31 - const beforeRequest = async (options: RequestOptions) => { 31 + const beforeRequest = async < 32 + TData = unknown, 33 + TResponseStyle extends 'data' | 'fields' = 'fields', 34 + ThrowOnError extends boolean = boolean, 35 + Url extends string = string, 36 + >( 37 + options: RequestOptions<TData, TResponseStyle, ThrowOnError, Url>, 38 + ) => { 32 39 const opts = { 33 40 ..._config, 34 41 ...options, ··· 56 63 opts.headers.delete('Content-Type'); 57 64 } 58 65 59 - const url = buildUrl(opts); 66 + const resolvedOpts = opts as typeof opts & 67 + ResolvedRequestOptions<TResponseStyle, ThrowOnError, Url>; 68 + const url = buildUrl(resolvedOpts); 60 69 61 - return { opts, url }; 70 + return { opts: resolvedOpts, url }; 62 71 }; 63 72 64 73 const parseErrorResponse = async ( ··· 105 114 }; 106 115 107 116 const request: Client['request'] = async (options) => { 108 - // @ts-expect-error 109 117 const { opts, url } = await beforeRequest(options); 110 118 111 119 const kyInstance = opts.ky!;
+10 -4
packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts
··· 29 29 30 30 const interceptors = createInterceptors<Response, unknown, ResolvedRequestOptions>(); 31 31 32 - const beforeRequest = async (options: RequestOptions) => { 32 + const beforeRequest = async < 33 + TData = unknown, 34 + ThrowOnError extends boolean = boolean, 35 + Url extends string = string, 36 + >( 37 + options: RequestOptions<TData, ThrowOnError, Url>, 38 + ) => { 33 39 const opts = { 34 40 ..._config, 35 41 ...options, ··· 58 64 opts.headers.delete('Content-Type'); 59 65 } 60 66 61 - const url = buildUrl(opts); 67 + const resolvedOpts = opts as typeof opts & ResolvedRequestOptions<ThrowOnError, Url>; 68 + const url = buildUrl(resolvedOpts); 62 69 63 - return { opts, url }; 70 + return { opts: resolvedOpts, url }; 64 71 }; 65 72 66 73 // @ts-expect-error 67 74 const request: Client['request'] = async (options) => { 68 - // @ts-expect-error 69 75 const { opts, url } = await beforeRequest(options); 70 76 71 77 for (const fn of interceptors.request.fns) {