Skip to content

Commit d4f1bc7

Browse files
Merge branch 'Hossein-s-fix-create-param-decorator'
2 parents 8d367c4 + 3ee0650 commit d4f1bc7

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

packages/common/decorators/http/create-route-param-metadata.decorator.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ export function createParamDecorator(
4848

4949
const isPipe = (pipe: any) =>
5050
pipe &&
51-
((isFunction(pipe) && pipe.prototype) || isFunction(pipe.transform));
51+
((isFunction(pipe) && pipe.prototype && isFunction(pipe.prototype.transform)) ||
52+
isFunction(pipe.transform));
5253

5354
const hasParamData = isNil(data) || !isPipe(data);
5455
const paramData = hasParamData ? data : undefined;

packages/common/test/decorators/create-param-decorator.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,24 @@ describe('createParamDecorator', () => {
8888
});
8989
});
9090
});
91+
92+
describe('when class type passed as data', () => {
93+
class Data { }
94+
class Test {
95+
public test(
96+
@Decorator(Data) prop,
97+
) { }
98+
}
99+
100+
it('should return class type as data parameter', () => {
101+
const metadata = Reflect.getMetadata(
102+
ROUTE_ARGS_METADATA,
103+
Test,
104+
'test',
105+
);
106+
const key = Object.keys(metadata)[0];
107+
expect(metadata[key].data).to.equal(Data);
108+
});
109+
});
91110
});
92111
});

0 commit comments

Comments
 (0)