typestack / class-transformer

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

fix: Expose not working correctly with toClassOnly #1692

Closed kpiatkowski closed 2 months ago

kpiatkowski commented 3 months ago

Description

I have data that is incoming from 3rd party provider, and I need to transform properties to my internal structure and be able to export it that way too. Basically I just need to transform keys while importing.

class TestClass {
  @Expose({ name: "Test", toClassOnly: true })
  public test: string;
}

const instance = plainToInstance(TestClass, { Test: "something" });
const plain = instanceToPlain(instance);

console.log(instance);
console.log(plain);

Expected behavior

TestClass { test: 'something' }
{ test: 'something' }

Actual behavior

TestClass { test: 'something' }
{ Test: 'something' }
diffy0712 commented 2 months ago

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

github-actions[bot] commented 1 month 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.