Skip to content

Commit 1139ee0

Browse files
committed
refactor: remove router structure check overhead
1 parent e4edb4c commit 1139ee0

File tree

1 file changed

+38
-40
lines changed

1 file changed

+38
-40
lines changed

packages/fetch/src/core/router.ts

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -200,47 +200,45 @@ type BuildRouterUrlFromStructure<
200200
RouterBuilderStructure,
201201
BaseUrl extends string = '',
202202
PathParamsList extends ReadonlyArray<string> = [],
203-
> = RouterBuilderStructure extends BuilderStructure
204-
? {
205-
[Key in keyof RouterBuilderStructure]: Key extends FetchMethod
206-
? RouterBuilderStructure[Key] extends FetchBuilder<
207-
string,
208-
unknown,
209-
infer SearchParams,
210-
infer Body,
211-
infer Response,
212-
infer IsJsonMode,
213-
string
203+
> = {
204+
[Key in keyof RouterBuilderStructure]: Key extends FetchMethod
205+
? RouterBuilderStructure[Key] extends FetchBuilder<
206+
string,
207+
unknown,
208+
infer SearchParams,
209+
infer Body,
210+
infer Response,
211+
infer IsJsonMode,
212+
string
213+
>
214+
? FetchUnit<
215+
Key,
216+
PathParamsList[number] extends []
217+
? unknown
218+
: {
219+
[CollectedPathParamsList in PathParamsList[number]]: Param
220+
},
221+
SearchParams,
222+
Body,
223+
Response,
224+
IsJsonMode,
225+
BaseUrl
226+
>
227+
: never
228+
: Key extends string
229+
? IsDynamicPath<Key> extends true
230+
? BuildRouterUrlFromStructure<
231+
RouterBuilderStructure[Key],
232+
`${BaseUrl}/${string}`,
233+
readonly [...PathParamsList, GetDynamicPath<Key>]
214234
>
215-
? FetchUnit<
216-
Key,
217-
PathParamsList[number] extends []
218-
? unknown
219-
: {
220-
[CollectedPathParamsList in PathParamsList[number]]: Param
221-
},
222-
SearchParams,
223-
Body,
224-
Response,
225-
IsJsonMode,
226-
BaseUrl
227-
>
228-
: never
229-
: Key extends string
230-
? IsDynamicPath<Key> extends true
231-
? BuildRouterUrlFromStructure<
232-
RouterBuilderStructure[Key],
233-
`${BaseUrl}/${string}`,
234-
readonly [...PathParamsList, GetDynamicPath<Key>]
235-
>
236-
: BuildRouterUrlFromStructure<
237-
RouterBuilderStructure[Key],
238-
`${BaseUrl}/${Key}`,
239-
PathParamsList
240-
>
241-
: never
242-
}
243-
: never
235+
: BuildRouterUrlFromStructure<
236+
RouterBuilderStructure[Key],
237+
`${BaseUrl}/${Key}`,
238+
PathParamsList
239+
>
240+
: never
241+
}
244242

245243
/**
246244
* Extract router config

0 commit comments

Comments
 (0)