class-transformer icon indicating copy to clipboard operation
class-transformer copied to clipboard

fix: DiscriminatorDescriptor interface now accepts number, too

Open MickL opened this issue 4 years ago • 5 comments

When using an enum as name it works fine by adding //@ts-ignore but the interface didnt allow that.

@ValidateNested()
  @Type(() => MyDto, {
    discriminator: {
      property: 'type',
      subTypes: [
        {value: MySubDto1, name: MyEnum.Something},
        {value: MySubDto2, name: MyEnum.SomethingOther},
      ],
    },
    keepDiscriminatorProperty: true,
  })
  cupData: MySubDto1 | MySubDto2;

Description

I changed the interface to accept string OR number.

Checklist

  • [x] the pull request title describes what this PR does (not a vague title like Update index.md)
  • [ x the pull request targets the default branch of the repository (develop)
  • [x] the code follows the established code style of the repository
    • npm run prettier:check passes
    • npm run lint:check passes
  • [ ] tests are added for the changes I made (if any source code was modified)
  • [ ] documentation added or updated
  • [x] I have run the project locally and verified that there are no errors

MickL avatar Feb 12 '21 11:02 MickL

Not sure what I can do about the semantic pull request but if one of the maintainers might fix it or tell me what to do that would be awesome :)

MickL avatar Feb 14 '21 15:02 MickL

Can this be merged?

MickL avatar Feb 23 '21 17:02 MickL

@NoNameProvided

MickL avatar Apr 15 '21 15:04 MickL

Sorry @NoNameProvided I dont understand what is meant with semantic commit and pr title. This is just a very very simple change in the TS interface but the PR is open for more than 4 months now :(

MickL avatar Jun 22 '21 09:06 MickL

Its been 2.5 years and the issue still persists. Can this PR finally be merged? @NoNameProvided

MickL avatar Jun 14 '23 17:06 MickL