Skip to content

Commit 2efb79d

Browse files
committed
fix: 'propertyKey' add undefined to union type
1 parent 9fa80ef commit 2efb79d

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

projects/ngx-http-decorators/src/lib/decorators/body.decorator.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ const BODY_METADATA = Symbol('ngx-http-decorators-meta:body');
1717
export function Body(): ParameterDecorator {
1818
return function (
1919
target: Object,
20-
propertyKey: string | symbol,
20+
propertyKey: string | symbol | undefined,
2121
parameterIndex: number
2222
): void {
23+
if (propertyKey === undefined) {
24+
throw new Error('@Body decorator should define propertyKey argument ');
25+
}
26+
2327
Reflect.defineMetadata(BODY_METADATA, parameterIndex, target, propertyKey);
2428
};
2529
}

projects/ngx-http-decorators/src/lib/decorators/param.decorator.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export type PathParams = { [param: string]: any };
3030
export function Param(name: string): ParameterDecorator {
3131
return function (
3232
target: Object,
33-
propertyKey: string | symbol,
33+
propertyKey: string | symbol | undefined,
3434
parameterIndex: number
3535
): void {
3636
extendObjectMetadata(
@@ -61,9 +61,13 @@ export function Param(name: string): ParameterDecorator {
6161
export function Params(): ParameterDecorator {
6262
return function (
6363
target: Object,
64-
propertyKey: string | symbol,
64+
propertyKey: string | symbol | undefined,
6565
parameterIndex: number
6666
): void {
67+
if (propertyKey === undefined) {
68+
throw new Error('@Params decorator should define propertyKey argument ');
69+
}
70+
6771
Reflect.defineMetadata(
6872
PATH_PARAMS_METADATA,
6973
parameterIndex,

projects/ngx-http-decorators/src/lib/decorators/query.decorator.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export type QueryParams = { [param: string]: any };
3131
export function Query(name: string): ParameterDecorator {
3232
return function (
3333
target: Object,
34-
propertyKey: string | symbol,
34+
propertyKey: string | symbol | undefined,
3535
parameterIndex: number
3636
): void {
3737
extendObjectMetadata(
@@ -63,9 +63,13 @@ export function Query(name: string): ParameterDecorator {
6363
export function Queries(): ParameterDecorator {
6464
return function (
6565
target: Object,
66-
propertyKey: string | symbol,
66+
propertyKey: string | symbol | undefined,
6767
parameterIndex: number
6868
): void {
69+
if (propertyKey === undefined) {
70+
throw new Error('@Queries decorator should define propertyKey argument ');
71+
}
72+
6973
Reflect.defineMetadata(
7074
QUERY_PARAMS_METADATA,
7175
parameterIndex,

0 commit comments

Comments
 (0)