#Automapper not working for nestjs v10

1 messages · Page 1 of 1 (latest)

burnt karma
#

previously I worked on nest v9 project for that automapper worked perfectly, but when it comes to v10, @automapper/nestjs for this package i have to install it forcibly.

import { User } from '@/domain/models/user';
import { Mapper, createMap } from '@automapper/core';
import { AutomapperProfile, InjectMapper } from '@automapper/nestjs';
import { Injectable } from '@nestjs/common';
import { CreateUserDto } from './create-user.dto';

@Injectable()
export class UserMapperProfile extends AutomapperProfile {
  constructor(@InjectMapper() mapper: Mapper) {
    super(mapper);
  }
  override get profile() {
    return (mapper: Mapper) => {
      createMap(mapper, CreateUserDto, User);
    };
  }
}

for the injectmapper it shoes this error, previous time, I set the ts check in vs code to workspace settings and avoid that isuue, This time it wont help to me.

Are there any fixes for new nest v10

regal vortex
#

That's due to a change in Typescript v5.2 (I think). It's generally ignorable and just a type error

burnt karma
burnt karma
sour bridge
burnt karma
sour bridge
#

Automappers in my opinion are a nightmare to work with, doing it manually actually gives you feedback during development

rocky citrus
#

I'm having the same issue here when trying to upgrade to 10x and also realised automapper is not an official module, which made me reconsider using it, but the only response mapping related documentation from the official website is https://docs.nestjs.com/interceptors#response-mapping

#

@sour bridge agree with automapper being a nightmare. The profiles required to map wont get check in the DI system and you will only find the issue when the mapper function is called in runtime ...