nartc / mapper

🔥 An Object-Object AutoMapper for TypeScript 🔥
https://automapperts.netlify.app/
MIT License
961 stars 84 forks source link

Properties with name in camel case renders as undefined #597

Closed maxime-aubry closed 4 months ago

maxime-aubry commented 4 months ago

Is there an existing issue for this?

Describe the issue

If a property has a name in camel case, this one is never rendered. so country take the good value for country property, but countryId is always undefined... BUT, if i replace countryId by countryid, it works ! Unhopefully, i can't change the names. So it must work with countryId.

Models/DTOs/VMs

class Source {
  @AutoMap()
  country!: string;

  @AutoMap()
  countryId!: string;
}

class Destination {
  @AutoMap()
  country!: string;

  @AutoMap()
  countryId!: string;
}

Mapping configuration

export const mapper: Mapper = createMapper({
  strategyInitializer: classes(),
  namingConventions: {
    source: new CamelCaseNamingConvention(),
    destination: new CamelCaseNamingConvention(),
  }
});

createMap(
    mapper,
    ClientHierarchyCountryDto,
    ClientHierarchyCountryState,
  );

Steps to reproduce

No response

Expected behavior

Country has the good value, but countryId of destination class should not be undefined. Naming convention is always Camel case into my code.

Screenshots

No response

Minimum reproduction code

No response

Package

Other package and its version

No response

AutoMapper version

8.8.1

Additional context

No response

maxime-aubry commented 4 months ago

Ok i found information. I use vite, which uses esBuild, that does not support emitDecoratorMetadata. What can i do ?

maxime-aubry commented 4 months ago

so this is the solution : i had this into vite.config.ts

optimizeDeps: {
      esbuildOptions: {
        tsconfig: 'tsconfig.json',
      },
    },