typestack / class-transformer

Decorator-based transformation, serialization, and deserialization between objects and classes.
MIT License
6.75k stars 493 forks source link

fix: plainToInstance 实例化不到 @Expose() get xxx #1726

Closed 2395000206 closed 1 month ago

2395000206 commented 1 month ago

Description

class User { @Exclude() leader_group: Group;

@Expose() get isLeaderGroup() :boolean { return !!this.leader_group } } const user = { leader_group: { name: 'aaa' } } const row = plainToInstance(Users, user ) console.log(row)

// 实际打印 { } , 希望打印 { isLeaderGroup: true }



### Expected behavior
{ isLeaderGroup: true }

### Actual behavior
{ }
heifengli001 commented 1 month ago

Use other methods to implement it. This version from 3 years ago hasn't been released for a long time //CN :使用其他方法实现吧,这个3年前的版本了,很久没有release了 @Expose() @Transform(({ obj }) => !!obj. leader_group) isLeaderGroup: boolean;

fingerart commented 1 month ago

Use other methods to implement it. This version from 3 years ago hasn't been released for a long time //CN :使用其他方法实现吧,这个3年前的版本了,很久没有release了 @expose() @Transform(({ obj }) => !!obj. leader_group) isLeaderGroup: boolean;

还有什么类似好用的库?

diffy0712 commented 1 month ago

The issue does not contain a simple reproduction case and does not use plain English.

Closing as invalid.

github-actions[bot] commented 1 week ago

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.