Skip to content

Commit b18f18d

Browse files
committed
Fix error typing
1 parent 981b010 commit b18f18d

File tree

3 files changed

+21
-49
lines changed

3 files changed

+21
-49
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"changes":{"packages/core/package.json":"Patch","packages/generator/package.json":"Patch","packages/rsbuild-plugin/package.json":"Patch","packages/fetch/package.json":"Patch","packages/utils/package.json":"Patch","packages/webpack-plugin/package.json":"Patch","packages/next-plugin/package.json":"Patch","packages/vite-plugin/package.json":"Patch"},"note":"Fix error typing","date":"2025-11-29T01:19:41.509961900Z"}

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,12 @@ bun run lint:fix
349349

350350
---
351351

352+
## 🙏 Acknowledgments
353+
354+
This project is inspired by [openapi-fetch](https://github.com/drwpow/openapi-typescript/tree/main/packages/openapi-fetch), a fantastic library for type-safe API clients. devup-api builds upon similar concepts while providing additional features like build-time type generation and seamless integration with modern build tools.
355+
356+
---
357+
352358
## 📄 License
353359

354360
Apache 2.0

packages/fetch/src/api.ts

Lines changed: 14 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import { convertResponse } from './response-converter'
2020
import { getUrlWithMethod } from './url-map'
2121
import { getApiEndpoint, isPlainObject } from './utils'
2222

23-
type DevupApiResponse<T, E = unknown> =
23+
// biome-ignore lint/suspicious/noExplicitAny: any is used to allow for flexibility in the type
24+
type DevupApiResponse<T, E = any> =
2425
| {
2526
data: T
2627
error?: undefined
@@ -50,10 +51,7 @@ export class DevupApi {
5051
? [options?: DevupApiRequestInit]
5152
: [options: DevupApiRequestInit & Omit<O, 'response' | 'error'>]
5253
): Promise<
53-
DevupApiResponse<
54-
ExtractValue<O, 'response'>,
55-
ExtractValue<O, 'error', unknown>
56-
>
54+
DevupApiResponse<ExtractValue<O, 'response'>, ExtractValue<O, 'error'>>
5755
> {
5856
return this.request(path, {
5957
method: 'GET',
@@ -70,10 +68,7 @@ export class DevupApi {
7068
? [options?: DevupApiRequestInit]
7169
: [options: DevupApiRequestInit & Omit<O, 'response'>]
7270
): Promise<
73-
DevupApiResponse<
74-
ExtractValue<O, 'response'>,
75-
ExtractValue<O, 'error', unknown>
76-
>
71+
DevupApiResponse<ExtractValue<O, 'response'>, ExtractValue<O, 'error'>>
7772
> {
7873
return this.request(path, {
7974
method: 'GET',
@@ -90,10 +85,7 @@ export class DevupApi {
9085
? [options?: DevupApiRequestInit]
9186
: [options: DevupApiRequestInit & Omit<O, 'response'>]
9287
): Promise<
93-
DevupApiResponse<
94-
ExtractValue<O, 'response'>,
95-
ExtractValue<O, 'error', unknown>
96-
>
88+
DevupApiResponse<ExtractValue<O, 'response'>, ExtractValue<O, 'error'>>
9789
> {
9890
return this.request(path, {
9991
method: 'POST',
@@ -110,10 +102,7 @@ export class DevupApi {
110102
? [options?: DevupApiRequestInit]
111103
: [options: DevupApiRequestInit & Omit<O, 'response'>]
112104
): Promise<
113-
DevupApiResponse<
114-
ExtractValue<O, 'response'>,
115-
ExtractValue<O, 'error', unknown>
116-
>
105+
DevupApiResponse<ExtractValue<O, 'response'>, ExtractValue<O, 'error'>>
117106
> {
118107
return this.request(path, {
119108
method: 'POST',
@@ -130,10 +119,7 @@ export class DevupApi {
130119
? [options?: DevupApiRequestInit]
131120
: [options: DevupApiRequestInit & Omit<O, 'response'>]
132121
): Promise<
133-
DevupApiResponse<
134-
ExtractValue<O, 'response'>,
135-
ExtractValue<O, 'error', unknown>
136-
>
122+
DevupApiResponse<ExtractValue<O, 'response'>, ExtractValue<O, 'error'>>
137123
> {
138124
return this.request(path, {
139125
method: 'PUT',
@@ -150,10 +136,7 @@ export class DevupApi {
150136
? [options?: DevupApiRequestInit]
151137
: [options: DevupApiRequestInit & Omit<O, 'response'>]
152138
): Promise<
153-
DevupApiResponse<
154-
ExtractValue<O, 'response'>,
155-
ExtractValue<O, 'error', unknown>
156-
>
139+
DevupApiResponse<ExtractValue<O, 'response'>, ExtractValue<O, 'error'>>
157140
> {
158141
return this.request(path, {
159142
method: 'PUT',
@@ -170,10 +153,7 @@ export class DevupApi {
170153
? [options?: DevupApiRequestInit]
171154
: [options: DevupApiRequestInit & Omit<O, 'response'>]
172155
): Promise<
173-
DevupApiResponse<
174-
ExtractValue<O, 'response'>,
175-
ExtractValue<O, 'error', unknown>
176-
>
156+
DevupApiResponse<ExtractValue<O, 'response'>, ExtractValue<O, 'error'>>
177157
> {
178158
return this.request(path, {
179159
method: 'DELETE',
@@ -190,10 +170,7 @@ export class DevupApi {
190170
? [options?: DevupApiRequestInit]
191171
: [options: DevupApiRequestInit & Omit<O, 'response'>]
192172
): Promise<
193-
DevupApiResponse<
194-
ExtractValue<O, 'response'>,
195-
ExtractValue<O, 'error', unknown>
196-
>
173+
DevupApiResponse<ExtractValue<O, 'response'>, ExtractValue<O, 'error'>>
197174
> {
198175
return this.request(path, {
199176
method: 'DELETE',
@@ -210,10 +187,7 @@ export class DevupApi {
210187
? [options?: DevupApiRequestInit]
211188
: [options: DevupApiRequestInit & Omit<O, 'response'>]
212189
): Promise<
213-
DevupApiResponse<
214-
ExtractValue<O, 'response'>,
215-
ExtractValue<O, 'error', unknown>
216-
>
190+
DevupApiResponse<ExtractValue<O, 'response'>, ExtractValue<O, 'error'>>
217191
> {
218192
return this.request(path, {
219193
method: 'PATCH',
@@ -230,10 +204,7 @@ export class DevupApi {
230204
? [options?: DevupApiRequestInit]
231205
: [options: DevupApiRequestInit & Omit<O, 'response'>]
232206
): Promise<
233-
DevupApiResponse<
234-
ExtractValue<O, 'response'>,
235-
ExtractValue<O, 'error', unknown>
236-
>
207+
DevupApiResponse<ExtractValue<O, 'response'>, ExtractValue<O, 'error'>>
237208
> {
238209
return this.request(path, {
239210
method: 'PATCH',
@@ -247,10 +218,7 @@ export class DevupApi {
247218
? [options?: DevupApiRequestInit]
248219
: [options: DevupApiRequestInit & Omit<O, 'response'>]
249220
): Promise<
250-
DevupApiResponse<
251-
ExtractValue<O, 'response'>,
252-
ExtractValue<O, 'error', unknown>
253-
>
221+
DevupApiResponse<ExtractValue<O, 'response'>, ExtractValue<O, 'error'>>
254222
> {
255223
const { method, url } = getUrlWithMethod(path)
256224
const mergedOptions = {
@@ -282,10 +250,7 @@ export class DevupApi {
282250
return fetch(request).then((response) =>
283251
convertResponse(request, response),
284252
) as Promise<
285-
DevupApiResponse<
286-
ExtractValue<O, 'response'>,
287-
ExtractValue<O, 'error', unknown>
288-
>
253+
DevupApiResponse<ExtractValue<O, 'response'>, ExtractValue<O, 'error'>>
289254
>
290255
}
291256

0 commit comments

Comments
 (0)