Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PickType doesn't carry over property level@Expose decorators #1369

Open
2 of 4 tasks
erikash opened this issue Apr 16, 2024 · 0 comments
Open
2 of 4 tasks

PickType doesn't carry over property level@Expose decorators #1369

erikash opened this issue Apr 16, 2024 · 0 comments

Comments

@erikash
Copy link

erikash commented Apr 16, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

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"}

Minimum reproduction code

https://github.com/erikash/picktype

Steps to reproduce

  1. pnpm start:dev
  2. curl http://localhost:3000/picktype

use this to see the expected result
3. curl http://localhost:3000/inheritence

Expected behavior

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.

Package version

2.0.5

Node.js version

18.17.1

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant