Skip to content

Commit 01307b1

Browse files
committed
Fix typing
1 parent 3fa34e4 commit 01307b1

File tree

4 files changed

+40
-19
lines changed

4 files changed

+40
-19
lines changed

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"useIgnoreFile": true
77
},
88
"files": {
9-
"includes": ["**", "!**/dist", "!.changepacks/**"]
9+
"includes": ["**", "!**/dist", "!.changepacks"]
1010
},
1111
"javascript": {
1212
"formatter": {

bun.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@
8484
},
8585
"packages/core": {
8686
"name": "@devup-api/core",
87-
"version": "0.1.0",
87+
"version": "0.0.0",
8888
"devDependencies": {
8989
"@types/node": "^24.10",
9090
"typescript": "^5.9",
9191
},
9292
},
9393
"packages/fetch": {
9494
"name": "@devup-api/fetch",
95-
"version": "0.1.0",
95+
"version": "0.0.0",
9696
"dependencies": {
9797
"@devup-api/core": "workspace:*",
9898
},
@@ -103,7 +103,7 @@
103103
},
104104
"packages/generator": {
105105
"name": "@devup-api/generator",
106-
"version": "0.1.0",
106+
"version": "0.0.0",
107107
"dependencies": {
108108
"@devup-api/core": "workspace:*",
109109
"@devup-api/utils": "workspace:*",
@@ -116,7 +116,7 @@
116116
},
117117
"packages/next-plugin": {
118118
"name": "@devup-api/next-plugin",
119-
"version": "0.1.0",
119+
"version": "0.0.0",
120120
"dependencies": {
121121
"@devup-api/core": "workspace:*",
122122
"@devup-api/generator": "workspace:*",
@@ -135,7 +135,7 @@
135135
},
136136
"packages/rsbuild-plugin": {
137137
"name": "@devup-api/rsbuild-plugin",
138-
"version": "0.1.0",
138+
"version": "0.0.0",
139139
"dependencies": {
140140
"@devup-api/core": "workspace:*",
141141
"@devup-api/generator": "workspace:*",
@@ -152,7 +152,7 @@
152152
},
153153
"packages/utils": {
154154
"name": "@devup-api/utils",
155-
"version": "0.1.0",
155+
"version": "0.0.0",
156156
"devDependencies": {
157157
"@types/node": "^24.10",
158158
"openapi-types": "^12.1",
@@ -161,7 +161,7 @@
161161
},
162162
"packages/vite-plugin": {
163163
"name": "@devup-api/vite-plugin",
164-
"version": "0.1.0",
164+
"version": "0.0.0",
165165
"dependencies": {
166166
"@devup-api/core": "workspace:*",
167167
"@devup-api/generator": "workspace:*",
@@ -178,7 +178,7 @@
178178
},
179179
"packages/webpack-plugin": {
180180
"name": "@devup-api/webpack-plugin",
181-
"version": "0.1.0",
181+
"version": "0.0.0",
182182
"dependencies": {
183183
"@devup-api/core": "workspace:*",
184184
"@devup-api/generator": "workspace:*",

packages/generator/src/__tests__/create-url-map.test.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { expect, test } from 'bun:test'
2+
import type { UrlMapValue } from '@devup-api/core'
23
import type { OpenAPIV3_1 } from 'openapi-types'
34
import { createUrlMap } from '../create-url-map'
45

@@ -55,7 +56,7 @@ test.each([
5556

5657
const result = createUrlMap(schema, options)
5758

58-
expect(result).toEqual(expected)
59+
expect(result).toEqual(expected as Record<string, UrlMapValue>)
5960
})
6061

6162
test('converts path parameters based on convertCase', () => {
@@ -109,9 +110,13 @@ test.each([
109110
const result = createUrlMap(schema)
110111

111112
expect(result).toHaveProperty(expectedKey)
112-
expect(result[expectedKey].method).toBe(expectedMethod)
113+
expect(result[expectedKey]?.method).toBe(
114+
expectedMethod as 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH',
115+
)
113116
expect(result).toHaveProperty('/users')
114-
expect(result['/users'].method).toBe(expectedMethod)
117+
expect(result['/users']?.method).toBe(
118+
expectedMethod as 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH',
119+
)
115120
})
116121

117122
test('handles operation without operationId', () => {
@@ -182,19 +187,21 @@ test('handles undefined paths', () => {
182187
const schema: OpenAPIV3_1.Document = {
183188
openapi: '3.1.0',
184189
info: { title: 'Test API', version: '1.0.0' },
190+
components: {},
191+
paths: {},
185192
}
186193

187194
const result = createUrlMap(schema)
188195

189196
expect(result).toEqual({})
190197
})
191198

192-
test('handles null pathItem', () => {
199+
test('handles undefined pathItem', () => {
193200
const schema: OpenAPIV3_1.Document = {
194201
openapi: '3.1.0',
195202
info: { title: 'Test API', version: '1.0.0' },
196203
paths: {
197-
'/users': null,
204+
'/users': undefined,
198205
},
199206
}
200207

@@ -282,7 +289,7 @@ test.each([
282289
convertCase: caseType as 'camel' | 'snake' | 'pascal',
283290
})
284291

285-
expect(result[expectedPath].url).toBe(expectedUrl)
292+
expect(result[expectedPath]?.url).toBe(expectedUrl)
286293
})
287294

288295
test.each([

packages/vite-plugin/src/__tests__/plugin.test.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ test.each([
8989
expect(plugin.config).toBeDefined()
9090
expect(typeof plugin.config).toBe('function')
9191

92-
const result = await plugin.config?.()
92+
const result = await (
93+
plugin as unknown as {
94+
config?: () => Promise<{ define: Record<string, string> }>
95+
}
96+
).config?.()
9397
expect(mockReadOpenapiAsync).toHaveBeenCalledWith(options?.openapiFile)
9498
expect(mockCreateUrlMap).toHaveBeenCalledWith(mockSchema, options)
9599
expect(result).toEqual({
@@ -104,7 +108,11 @@ test.each([
104108
test('devupApi config hook returns empty define when urlMap is null', async () => {
105109
mockCreateUrlMap.mockReturnValue(null as never)
106110
const plugin = devupApi()
107-
const result = await plugin.config?.()
111+
const result = await (
112+
plugin as unknown as {
113+
config?: () => Promise<{ define: Record<string, string> }>
114+
}
115+
).config?.()
108116
expect(result).toEqual({
109117
define: {},
110118
})
@@ -113,7 +121,11 @@ test('devupApi config hook returns empty define when urlMap is null', async () =
113121
test('devupApi config hook returns empty define when urlMap is undefined', async () => {
114122
mockCreateUrlMap.mockReturnValue(undefined as never)
115123
const plugin = devupApi()
116-
const result = await plugin.config?.()
124+
const result = await (
125+
plugin as unknown as {
126+
config?: () => Promise<{ define: Record<string, string> }>
127+
}
128+
).config?.()
117129
expect(result).toEqual({
118130
define: {},
119131
})
@@ -137,7 +149,9 @@ test.each([
137149
expect(plugin.configResolved).toBeDefined()
138150
expect(typeof plugin.configResolved).toBe('function')
139151

140-
await plugin.configResolved?.()
152+
await (
153+
plugin as unknown as { configResolved?: () => Promise<void> }
154+
).configResolved?.()
141155
expect(mockCreateTmpDirAsync).toHaveBeenCalledWith(options?.tempDir)
142156
expect(mockReadOpenapiAsync).toHaveBeenCalledWith(options?.openapiFile)
143157
expect(mockGenerateInterface).toHaveBeenCalledWith(mockSchema, options)

0 commit comments

Comments
 (0)