typeorm: TypeScript 2.7.1 update cause repository.save(entity) error
Issue type:
[ ] question [x ] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[x ] postgres
[ ] sqlite
[ ] sqljs
[ ] websql
TypeORM version:
[ x] latest
[ ] @next
[ ] 0.x.x (or put your version here)
Steps to reproduce or a small repository showing the problem:
When i update my typescript version to 2.7.1 my application’s build broken with the follow error:
PS C:\dsv\nest-api> npm run start:prod
nest-typescript-starter@1.0.0 prestart:prod C:\dsv\nest-api tsc
src/modules/common/services/base-data.service.ts(46,65): error TS2321: Excessive stack depth comparing types ‘T’ and ‘DeepPartial<T>’. src/modules/common/services/base-data.service.ts(67,65): error TS2345: Argument of type ‘T’ is not assignable to parameter of type ‘DeepPartial<T>’.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! nest-typescript-starter@1.0.0 prestart:prod: tsc
npm ERR! Exit status 2
The service code is the follow:
export abstract class BaseDataService<T extends BaseModel> implements ICrudService<T>{
constructor() {
}
... other crud methods
public abstract getRepository(): Repository<T>;
public async save(entity: T): Promise<T> {
try {
const response: T = await this.getRepository().save(entity);
return response;
} catch (error) {
throw new BadGatewayException('ERROR.BASEDATASERVICE.SAVE');
}
}
}
Someone know why this is happening?
Thanks!
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 7
- Comments: 24 (11 by maintainers)
Can you guys please check it in the
0.2.15-rc.1? (npm i typeorm@0.2.15-rc.1)Downgrading to
0.2.15-rc.1did not fix the issue for me.I’ll close it, let’s track a typescript issue instead.
@aymehri To use it before the fix in TS 2.8.1, you just have to pass the entity as any.
@aymehri Microsoft/Typescript#21671 in favor of Microsoft/Typescript#21592 in which the Typescript Team acknowledged that it’s a bug. The current target for a fix is TypeScript 2.8.1
There is an issue open for that (Microsoft/TypeScript#21671). It seems like a regression issue on their part. Let’s see what they have to say.