Open erikash opened 6 months ago
class TestDto { firstname: string; lastname: string; @Expose({ toPlainOnly: true }) get fullName() { return `${this.firstname} ${this.lastname}`; } } class PickTestDto extends PickType(TestDto, [] as const) {} @Get('picktype') getPickTypeTest(): TestDto { const instance = plainToInstance(PickTestDto, { firstname: 'John', lastname: 'Doe', }); const plain = instanceToPlain(instance); return plain as unknown as TestDto; }
The API returns: {"firstname":"John","lastname":"Doe"}
{"firstname":"John","lastname":"Doe"}
https://github.com/erikash/picktype
pnpm start:dev
curl http://localhost:3000/picktype
use this to see the expected result
curl http://localhost:3000/inheritence
I would expect the Expose on get fullName to be inherited and the API to return{"firstname":"John","lastname":"Doe","fullName":"John Doe"} as per step 3) above.
Expose
get fullName
{"firstname":"John","lastname":"Doe","fullName":"John Doe"}
2.0.5
18.17.1
No response
Is there an existing issue for this?
Current behavior
The API returns:
{"firstname":"John","lastname":"Doe"}
Minimum reproduction code
https://github.com/erikash/picktype
Steps to reproduce
pnpm start:dev
curl http://localhost:3000/picktype
use this to see the expected result
curl http://localhost:3000/inheritence
Expected behavior
I would expect the
Expose
onget fullName
to be inherited and the API to return{"firstname":"John","lastname":"Doe","fullName":"John Doe"}
as per step 3) above.Package version
2.0.5
Node.js version
18.17.1
In which operating systems have you tested?
Other
No response