Skip to content

Commit dc554da

Browse files
authored
fix(core): broken params when pathParams is missing and zod is not installed (#550)
1 parent 5f70d75 commit dc554da

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

.changeset/long-colts-switch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@ts-rest/core': patch
3+
---
4+
5+
Fix `params` resolving as `any` when `pathParams` is missing and zod is not installed

libs/ts-rest/core/src/lib/infer-types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ type PathParamsFromUrl<T extends AppRoute> = ParamsFromUrl<
5151
type PathParamsWithCustomValidators<
5252
T extends AppRoute,
5353
TClientOrServer extends 'client' | 'server' = 'server',
54-
> = T['pathParams'] extends undefined
55-
? PathParamsFromUrl<T>
56-
: Merge<
54+
> = 'pathParams' extends keyof T
55+
? Merge<
5756
PathParamsFromUrl<T>,
5857
TClientOrServer extends 'server'
5958
? ZodInferOrType<T['pathParams']>
6059
: ZodInputOrType<T['pathParams']>
61-
>;
60+
>
61+
: PathParamsFromUrl<T>;
6262

6363
export type ResolveResponseType<
6464
T extends

0 commit comments

Comments
 (0)