nestjs / mapped-types

Configuration module for Nest framework (node.js) 🐺
https://nestjs.com
MIT License
378 stars 59 forks source link

Extending using PartialType, OmitType… doesn't copy properties decorators #1174

Closed mlbonniec closed 1 year ago

mlbonniec commented 1 year ago

Is there an existing issue for this?

Current behavior

Hi, I've noticed that when extending a class (Child) from another (Parent), using PartialType (for example, but this is the same with the other wrappers) doesn't add the Parent properties decorators to the Child.

How did I notice this ? I've some swagger @ApiProperty() decorators in my CreateDto, and when extending the UpdateDto extends PartialType(CreateDto) {}, the UpdateDto doesn't have any properties in the Swagger.``

However, removing the PartialType wrapper "fix" the issue.

Reproduction

https://stackblitz.com/edit/nestjs-issue-minimum-repro-starter-2zmyjl

Expected behavior

All the Parent properties decorators should be copied to the Child.

Package version

2.0.2

Node.js version

18.16.1

In which operating systems have you tested?

Other

No response

micalevisk commented 1 year ago

Please provide a minimum reproduction repository. You can start from this minimal project.

why reproductions are required

mlbonniec commented 1 year ago

@micalevisk I've updated the original message, sorry :)

kamilmysliwiec commented 1 year ago

If you're using swagger, then you should use PartialType from @nestjs/swagger, not @nestjs/mapped-types