Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .changeset/fix-error-interceptor-response-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hey-api/openapi-ts": patch
---

**plugin(@hey-api/client-fetch)**: type `response` as `Response | undefined` in error interceptors and error results, since `response` is `undefined` when the error originates from a fetch exception (e.g. network failure, AbortError)
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const createClient = (config: Config = {}): Client => {

for (const fn of interceptors.error.fns) {
if (fn) {
finalError = (await fn(error, undefined as any, request, opts)) as unknown;
finalError = (await fn(error, undefined, request, opts)) as unknown;
}
}

Expand All @@ -119,7 +119,7 @@ export const createClient = (config: Config = {}): Client => {
: {
error: finalError,
request,
response: undefined as any,
response: undefined,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export type RequestResult<
}
) & {
request: Request;
response: Response;
response: Response | undefined;
}
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export const mergeHeaders = (

type ErrInterceptor<Err, Res, Req, Options> = (
error: Err,
response: Res,
response: Res | undefined,
request: Req,
options: Options,
) => Err | Promise<Err>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const createClient = (config: Config = {}): Client => {

for (const fn of interceptors.error.fns) {
if (fn) {
finalError = (await fn(error, undefined as any, request, opts)) as unknown;
finalError = (await fn(error, undefined, request, opts)) as unknown;
}
}

Expand All @@ -119,7 +119,7 @@ export const createClient = (config: Config = {}): Client => {
: {
error: finalError,
request,
response: undefined as any,
response: undefined,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export type RequestResult<
}
) & {
request: Request;
response: Response;
response: Response | undefined;
}
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export const mergeHeaders = (

type ErrInterceptor<Err, Res, Req, Options> = (
error: Err,
response: Res,
response: Res | undefined,
request: Req,
options: Options,
) => Err | Promise<Err>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const createClient = (config: Config = {}): Client => {

for (const fn of interceptors.error.fns) {
if (fn) {
finalError = (await fn(error, undefined as any, request, opts)) as unknown;
finalError = (await fn(error, undefined, request, opts)) as unknown;
}
}

Expand All @@ -119,7 +119,7 @@ export const createClient = (config: Config = {}): Client => {
: {
error: finalError,
request,
response: undefined as any,
response: undefined,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export type RequestResult<
}
) & {
request: Request;
response: Response;
response: Response | undefined;
}
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export const mergeHeaders = (

type ErrInterceptor<Err, Res, Req, Options> = (
error: Err,
response: Res,
response: Res | undefined,
request: Req,
options: Options,
) => Err | Promise<Err>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const createClient = (config: Config = {}): Client => {

for (const fn of interceptors.error.fns) {
if (fn) {
finalError = (await fn(error, undefined as any, request, opts)) as unknown;
finalError = (await fn(error, undefined, request, opts)) as unknown;
}
}

Expand All @@ -119,7 +119,7 @@ export const createClient = (config: Config = {}): Client => {
: {
error: finalError,
request,
response: undefined as any,
response: undefined,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export type RequestResult<
}
) & {
request: Request;
response: Response;
response: Response | undefined;
}
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export const mergeHeaders = (

type ErrInterceptor<Err, Res, Req, Options> = (
error: Err,
response: Res,
response: Res | undefined,
request: Req,
options: Options,
) => Err | Promise<Err>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const createClient = (config: Config = {}): Client => {

for (const fn of interceptors.error.fns) {
if (fn) {
finalError = (await fn(error, undefined as any, request, opts)) as unknown;
finalError = (await fn(error, undefined, request, opts)) as unknown;
}
}

Expand All @@ -119,7 +119,7 @@ export const createClient = (config: Config = {}): Client => {
: {
error: finalError,
request,
response: undefined as any,
response: undefined,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export type RequestResult<
}
) & {
request: Request;
response: Response;
response: Response | undefined;
}
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export const mergeHeaders = (

type ErrInterceptor<Err, Res, Req, Options> = (
error: Err,
response: Res,
response: Res | undefined,
request: Req,
options: Options,
) => Err | Promise<Err>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const createClient = (config: Config = {}): Client => {

for (const fn of interceptors.error.fns) {
if (fn) {
finalError = (await fn(error, undefined as any, request, opts)) as unknown;
finalError = (await fn(error, undefined, request, opts)) as unknown;
}
}

Expand All @@ -119,7 +119,7 @@ export const createClient = (config: Config = {}): Client => {
: {
error: finalError,
request,
response: undefined as any,
response: undefined,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export type RequestResult<
}
) & {
request: Request;
response: Response;
response: Response | undefined;
}
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export const mergeHeaders = (

type ErrInterceptor<Err, Res, Req, Options> = (
error: Err,
response: Res,
response: Res | undefined,
request: Req,
options: Options,
) => Err | Promise<Err>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const createClient = (config: Config = {}): Client => {

for (const fn of interceptors.error.fns) {
if (fn) {
finalError = (await fn(error, undefined as any, request, opts)) as unknown;
finalError = (await fn(error, undefined, request, opts)) as unknown;
}
}

Expand All @@ -119,7 +119,7 @@ export const createClient = (config: Config = {}): Client => {
: {
error: finalError,
request,
response: undefined as any,
response: undefined,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export type RequestResult<
}
) & {
request: Request;
response: Response;
response: Response | undefined;
}
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export const mergeHeaders = (

type ErrInterceptor<Err, Res, Req, Options> = (
error: Err,
response: Res,
response: Res | undefined,
request: Req,
options: Options,
) => Err | Promise<Err>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const createClient = (config: Config = {}): Client => {

for (const fn of interceptors.error.fns) {
if (fn) {
finalError = (await fn(error, undefined as any, request, opts)) as unknown;
finalError = (await fn(error, undefined, request, opts)) as unknown;
}
}

Expand All @@ -119,7 +119,7 @@ export const createClient = (config: Config = {}): Client => {
: {
error: finalError,
request,
response: undefined as any,
response: undefined,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export type RequestResult<
}
) & {
request: Request;
response: Response;
response: Response | undefined;
}
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export const mergeHeaders = (

type ErrInterceptor<Err, Res, Req, Options> = (
error: Err,
response: Res,
response: Res | undefined,
request: Req,
options: Options,
) => Err | Promise<Err>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const createClient = (config: Config = {}): Client => {

for (const fn of interceptors.error.fns) {
if (fn) {
finalError = (await fn(error, undefined as any, request, opts)) as unknown;
finalError = (await fn(error, undefined, request, opts)) as unknown;
}
}

Expand All @@ -119,7 +119,7 @@ export const createClient = (config: Config = {}): Client => {
: {
error: finalError,
request,
response: undefined as any,
response: undefined,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export type RequestResult<
}
) & {
request: Request;
response: Response;
response: Response | undefined;
}
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export const mergeHeaders = (

type ErrInterceptor<Err, Res, Req, Options> = (
error: Err,
response: Res,
response: Res | undefined,
request: Req,
options: Options,
) => Err | Promise<Err>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const createClient = (config: Config = {}): Client => {

for (const fn of interceptors.error.fns) {
if (fn) {
finalError = (await fn(error, undefined as any, request, opts)) as unknown;
finalError = (await fn(error, undefined, request, opts)) as unknown;
}
}

Expand All @@ -119,7 +119,7 @@ export const createClient = (config: Config = {}): Client => {
: {
error: finalError,
request,
response: undefined as any,
response: undefined,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export type RequestResult<
}
) & {
request: Request;
response: Response;
response: Response | undefined;
}
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export const mergeHeaders = (

type ErrInterceptor<Err, Res, Req, Options> = (
error: Err,
response: Res,
response: Res | undefined,
request: Req,
options: Options,
) => Err | Promise<Err>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const createClient = (config: Config = {}): Client => {

for (const fn of interceptors.error.fns) {
if (fn) {
finalError = (await fn(error, undefined as any, request, opts)) as unknown;
finalError = (await fn(error, undefined, request, opts)) as unknown;
}
}

Expand All @@ -119,7 +119,7 @@ export const createClient = (config: Config = {}): Client => {
: {
error: finalError,
request,
response: undefined as any,
response: undefined,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export type RequestResult<
}
) & {
request: Request;
response: Response;
response: Response | undefined;
}
>;

Expand Down
Loading
Loading