Skip to content

Commit e74c0a0

Browse files
authored
Merge pull request #2290 from btmnk/improves-client-fetch-types
2 parents 7df6059 + 4a77615 commit e74c0a0

File tree

126 files changed

+504
-248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+504
-248
lines changed

.changeset/tall-papayas-pay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/openapi-ts": patch
3+
---
4+
5+
fix(client): improve types to pass `@total-typescript/ts-reset` rules

examples/openapi-ts-tanstack-angular-query-experimental/angular.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,8 @@
7171
}
7272
}
7373
}
74+
},
75+
"cli": {
76+
"analytics": false
7477
}
7578
}

packages/openapi-ts-tests/test/__snapshots__/2.0.x/body-response-text-plain/client/client.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,16 @@ export const createClient = (config: Config = {}): Client => {
143143
};
144144
}
145145

146-
let error = await response.text();
146+
const textError = await response.text();
147+
let jsonError: unknown;
147148

148149
try {
149-
error = JSON.parse(error);
150+
jsonError = JSON.parse(textError);
150151
} catch {
151152
// noop
152153
}
153154

155+
const error = jsonError ?? textError;
154156
let finalError = error;
155157

156158
for (const fn of interceptors.error._fns) {

packages/openapi-ts-tests/test/__snapshots__/2.0.x/form-data/client/client.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,16 @@ export const createClient = (config: Config = {}): Client => {
143143
};
144144
}
145145

146-
let error = await response.text();
146+
const textError = await response.text();
147+
let jsonError: unknown;
147148

148149
try {
149-
error = JSON.parse(error);
150+
jsonError = JSON.parse(textError);
150151
} catch {
151152
// noop
152153
}
153154

155+
const error = jsonError ?? textError;
154156
let finalError = error;
155157

156158
for (const fn of interceptors.error._fns) {

packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,16 @@ export const createClient = (config: Config = {}): Client => {
143143
};
144144
}
145145

146-
let error = await response.text();
146+
const textError = await response.text();
147+
let jsonError: unknown;
147148

148149
try {
149-
error = JSON.parse(error);
150+
jsonError = JSON.parse(textError);
150151
} catch {
151152
// noop
152153
}
153154

155+
const error = jsonError ?? textError;
154156
let finalError = error;
155157

156158
for (const fn of interceptors.error._fns) {

packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,16 @@ export const createClient = (config: Config = {}): Client => {
143143
};
144144
}
145145

146-
let error = await response.text();
146+
const textError = await response.text();
147+
let jsonError: unknown;
147148

148149
try {
149-
error = JSON.parse(error);
150+
jsonError = JSON.parse(textError);
150151
} catch {
151152
// noop
152153
}
153154

155+
const error = jsonError ?? textError;
154156
let finalError = error;
155157

156158
for (const fn of interceptors.error._fns) {

packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,16 @@ export const createClient = (config: Config = {}): Client => {
143143
};
144144
}
145145

146-
let error = await response.text();
146+
const textError = await response.text();
147+
let jsonError: unknown;
147148

148149
try {
149-
error = JSON.parse(error);
150+
jsonError = JSON.parse(textError);
150151
} catch {
151152
// noop
152153
}
153154

155+
const error = jsonError ?? textError;
154156
let finalError = error;
155157

156158
for (const fn of interceptors.error._fns) {

packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,16 @@ export const createClient = (config: Config = {}): Client => {
143143
};
144144
}
145145

146-
let error = await response.text();
146+
const textError = await response.text();
147+
let jsonError: unknown;
147148

148149
try {
149-
error = JSON.parse(error);
150+
jsonError = JSON.parse(textError);
150151
} catch {
151152
// noop
152153
}
153154

155+
const error = jsonError ?? textError;
154156
let finalError = error;
155157

156158
for (const fn of interceptors.error._fns) {

packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,16 @@ export const createClient = (config: Config = {}): Client => {
143143
};
144144
}
145145

146-
let error = await response.text();
146+
const textError = await response.text();
147+
let jsonError: unknown;
147148

148149
try {
149-
error = JSON.parse(error);
150+
jsonError = JSON.parse(textError);
150151
} catch {
151152
// noop
152153
}
153154

155+
const error = jsonError ?? textError;
154156
let finalError = error;
155157

156158
for (const fn of interceptors.error._fns) {

packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,16 @@ export const createClient = (config: Config = {}): Client => {
143143
};
144144
}
145145

146-
let error = await response.text();
146+
const textError = await response.text();
147+
let jsonError: unknown;
147148

148149
try {
149-
error = JSON.parse(error);
150+
jsonError = JSON.parse(textError);
150151
} catch {
151152
// noop
152153
}
153154

155+
const error = jsonError ?? textError;
154156
let finalError = error;
155157

156158
for (const fn of interceptors.error._fns) {

0 commit comments

Comments
 (0)