-
Notifications
You must be signed in to change notification settings - Fork 508
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
fix: plainToInstance will throw an error when exposing a getter in the parent class #1257
Comments
same problem |
same issue here I saw the PR has been raised up, any idea when this can be merged? |
Damn I just discovered the same! As workaround do I have to duplicate the getter on the extending class? For now I can Confirm that duplicating the getter with the decorators solved |
In our application the Expose decorator wasn't working for getters. Nothing gets passed along. So we copied the getters into the DTO as properties to avoid the getter issue, added the Transform decorator to each property that needed it, and applied the export class ExampleDto extends OmitType(ExampleEntity, [] as const) {
// ... removed for brevity
@Transform(({ obj }) => obj.whatever !== ‘something’, { toClassOnly: true })
public exampleField: boolean; // <--- is a getter in ExampleEntity that matches the Transform
} |
Who added the "status: fixed" label? It's not fixed...the problem still occurs if you don't replicate the decorators on the extended class... |
the README is very confusing
import { Expose } from 'class-transformer';
export class User {
id: number;
firstName: string;
lastName: string;
password: string;
@Expose()
get name() {
return this.firstName + ' ' + this.lastName;
}
@Expose()
getFullName() {
return this.firstName + ' ' + this.lastName;
}
} |
Description
Minimal code-snippet showcasing the problem
Expected behavior
Output:
Actual behavior
The text was updated successfully, but these errors were encountered: