Skip to content
Snippets Groups Projects
Unverified Commit 7d3c563d authored by vmaubert's avatar vmaubert Committed by GitHub
Browse files

refactor(type): simplifie le typage des urls (#615)

parent d04f13f1
No related branches found
No related tags found
No related merge requests found
...@@ -154,13 +154,7 @@ export const DOWNLOAD_FORMATS = { ...@@ -154,13 +154,7 @@ export const DOWNLOAD_FORMATS = {
export type DownloadFormat = (typeof DOWNLOAD_FORMATS)[keyof typeof DOWNLOAD_FORMATS] export type DownloadFormat = (typeof DOWNLOAD_FORMATS)[keyof typeof DOWNLOAD_FORMATS]
type ZodParseUrlParams<url> = url extends `${infer path}(${infer optionalPath})` type ZodParseUrlParams<url> = url extends `${infer start}/${infer rest}` ? ZodParseUrlParams<start> & ZodParseUrlParams<rest> : url extends `:${infer param}` ? { [k in param]: ZodType } : {} // eslint-disable-line @typescript-eslint/ban-types
? ZodParseUrlParams<path> & Partial<ZodParseUrlParams<optionalPath>>
: url extends `${infer start}/${infer rest}`
? ZodParseUrlParams<start> & ZodParseUrlParams<rest>
: url extends `:${infer param}`
? { [k in param]: ZodType }
: {} // eslint-disable-line @typescript-eslint/ban-types
type can<T, Method extends 'post' | 'get' | 'put' | 'delete' | 'download'> = T extends CaminoRestRoute ? ((typeof CaminoRestRoutes)[T] extends { [m in Method]: any } ? T : never) : never type can<T, Method extends 'post' | 'get' | 'put' | 'delete' | 'download'> = T extends CaminoRestRoute ? ((typeof CaminoRestRoutes)[T] extends { [m in Method]: any } ? T : never) : never
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment