domain-driven-hexagon icon indicating copy to clipboard operation
domain-driven-hexagon copied to clipboard

execute start:dev throws error

Open kljopu opened this issue 2 years ago • 6 comments

https://github.com/Sairyss/domain-driven-hexagon/blob/64387c47b07b941843d2f854fc358cde45051787/src/libs/ddd/infrastructure/database/base-classes/typeorm.repository.base.ts#L44-L47

when excute start:dev it throws error

src/libs/ddd/infrastructure/database/base-classes/typeorm.repository.base.ts:47:47 - error TS2769: No overload matches this call.
  Overload 1 of 4, '(entities: DeepPartial<OrmEntity>[], options?: SaveOptions | undefined): Promise<(DeepPartial<OrmEntity> & OrmEntity)[]>', gave the following error.
    Argument of type 'OrmEntity' is not assignable to parameter of type 'DeepPartial<OrmEntity>[]'.
  Overload 2 of 4, '(entity: DeepPartial<OrmEntity>, options?: SaveOptions | undefined): Promise<DeepPartial<OrmEntity> & OrmEntity>', gave the following error.
    Argument of type 'OrmEntity' is not assignable to parameter of type 'DeepPartial<OrmEntity>'.

47     const result = await this.repository.save(ormEntity);

what am i missing?

kljopu avatar Mar 24 '22 04:03 kljopu

I just tried starting the application and I don't get any error. Try deleting node_modules and installing them again maybe this will help.

Sairyss avatar Mar 24 '22 09:03 Sairyss

Thx for quick reply. Is there any opportunity that because of node version?

kljopu avatar Mar 25 '22 02:03 kljopu

I'm using version 16.14.0. I also tried using version 12.22.11 and it worked too. If you have much older version try running it with a newer version of node. You can use nvm or volta for that.

Sairyss avatar Mar 25 '22 09:03 Sairyss

Hi,

I have exactly the same issue here. Using:

  • Node 16.13.2
  • NestJS 8.0.0
  • NestJS/typeorm 8.0.3
  • typeorm 0.2.45

Already tried to delete the node_modules folder / npm upgrade / npm install --> no success

Any idea?

Thanks for your help.

pepsi92 avatar Mar 27 '22 09:03 pepsi92

This is caused by npm upgrade. Newer versions of TypeOrm have breaking changes. Skip the upgrade part and make sure you are using package-lock.json file provided in a repository (and not the one that gets updated by running npm upgrade)

Sairyss avatar Mar 27 '22 10:03 Sairyss

Many thanks for pointing me to the right direction.

It seems this issue appeared with typeorm 0.2.42 and is being investigated by the typeorm team (https://github.com/typeorm/typeorm/issues/8681). A fix has been merged yesterday but it seems some users still encounter some issue.

I've downgraded the typeorm package to version 0.2.41 and it is working again 👍🏻

pepsi92 avatar Mar 27 '22 19:03 pepsi92