typestack / class-transformer

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

fix: do not apply custom name for instanceToPlain on toClassOnly and exposeAll #1701

Open diffy0712 opened 1 month ago

diffy0712 commented 1 month ago

Description

The following code do not run as expected with 'exposeAll' strategy.

class User {
  @Expose({ name: 'pass', toClassOnly: true })
  password: string;
}

const user = new User();
user.password = 'StrongPassword'

const plainedUser = instanceToPlain(user, {strategy: 'exposeAll'});
expect(plainedUser).toEqual({
  password: 'StrongPassword',
});
/**
 * Fails
 * 
 * - Expected  - 1
 * + Received  + 1
 *
 *   Object {
 * -   "password": "StrongPassword",
 * +   "pass": "StrongPassword",
 *   }
 */

Checklist

Fixes

fixes https://github.com/typestack/class-transformer/issues/1324

jfelicianiats commented 1 month ago

@diffy0712 Hey thanks so much for the PR on this issue! Quick question though as I'm not familiar with this project on releases. When this gets merged, is there an estimate to when this will be released to a public npm version? It doesn't look like any releases have happened in a long time... or is there some other process now there?

diffy0712 commented 1 month ago

@jfelicianiats, Unfortunately, I cannot give an estimate on when this will be merged and released. Hopefully soon. I think you can follow this pr and get notified if anything happens.