Skip to content

Commit 8a8b606

Browse files
authored
refactor: type safe TsRest decorator (#157)
* refactor: type safe TsRest decorator * chore: changeset
1 parent 2bdfb31 commit 8a8b606

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

.changeset/fresh-dodos-try.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@ts-rest/nest': patch
3+
---
4+
5+
Increased type safety for the @TsRest decorator

libs/ts-rest/nest/src/lib/ts-rest.decorator.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@ export type TsRestOptions = {
2121
validateResponses?: boolean;
2222
};
2323

24+
type TsRestType = {
25+
(appRoute: AppRoute, options?: TsRestOptions): MethodDecorator;
26+
(options: TsRestOptions): ClassDecorator;
27+
};
28+
2429
/**
2530
* As a class decorator, you can configure ts-rest options. As a method decorator, you can assign the route and also configure options
2631
* @param appRouteOrOptions For a method decorator, this is the route. For a class decorator, this is the options
2732
* @param options For a method decorator, this is the options
2833
*/
29-
export const TsRest = (
34+
export const TsRest: TsRestType = (
3035
appRouteOrOptions: AppRoute | TsRestOptions,
3136
options: TsRestOptions = {}
3237
) => {

0 commit comments

Comments
 (0)