Skip to content

Bug - @Expose options toClassOnly and toPlainOnly are not respected #1351

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

Closed
codyburrito opened this issue Sep 30, 2022 · 3 comments
Closed
Labels
status: duplicate Issue is being tracked already in another issue.

Comments

@codyburrito
Copy link

interface User {
  @Expose({ name: 'sub', toClassOnly: true })
  id: string;
 
  @Expose({ name: 'first_name'})
  firstName: string;
}

const obj = { sub: '1234', first_name: 'bob'  };

const userInstance = plainToInstance(User, obj); // User { id: '1234', firstName: 'bob' }

const userPlain = instanceToPlain(userInstance); // { sub: '1234', first_name: 'bob' }

expect(userPlain).toEqual({ id: '1234', first_name: 'bob' })

Here is the possible place that the logic for these flags needs to be included

Relevant lines:

if (!this.options.ignoreDecorators && targetType) {

@pavelefimenko95
Copy link

any updates?

@diffy0712
Copy link

Duplicate of #1324

@diffy0712 diffy0712 marked this as a duplicate of #1324 May 5, 2024
@diffy0712 diffy0712 closed this as not planned Won't fix, can't repro, duplicate, stale May 5, 2024
@diffy0712 diffy0712 added the status: duplicate Issue is being tracked already in another issue. label May 5, 2024
Copy link

github-actions bot commented Jun 5, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: duplicate Issue is being tracked already in another issue.
Development

No branches or pull requests

3 participants