After reinstalling node_modules I am suddenly getting a FindOneOptions/ObjectID error in my NestJS service.
Was building fine minutes ago beforehand. Makes me wonder, is this a code err or a typings err?
Using "@nestjs/typeorm": "^7.1.5"
Which seems to be using typeorm 0.2.35:
Local installed version: 0.2.35.
Global installed TypeORM version: 0.2.37.
The actual code
async getOne(id: number, userId?: string, type?: XPType, currentUser?: User) {
const options: FindConditions<XP> = {
id
};
userId && (options.userId = userId);
type && (options.type = type);
const post = await XP.findOne(options); // <-- error
...
Here is the actual error:
No overload matches this call.
Overload 1 of 3, '(this: ObjectType<XP>, id?: string | number | Date | ObjectID, options?: FindOneOptions<XP>): Promise<...>', gave the following error.
Argument of type 'FindConditions<XP>' is not assignable to parameter of type 'string | number | Date | ObjectID'.
Type 'FindConditions<XP>' is missing the following properties from type 'ObjectID': generationTime, equals, generate, getTimestamp, toHexString
Overload 2 of 3, '(this: ObjectType<XP>, options?: FindOneOptions<XP>): Promise<XP>', gave the following error.
Type 'FindConditions<XP>' has no properties in common with type 'FindOneOptions<XP>'.
Overload 3 of 3, '(this: ObjectType<XP>, conditions?: FindConditions<XP>, options?: FindOneOptions<XP>): Promise<...>', gave the following error.
Argument of type 'import("/Users/bracicot/dev/dev-server/dev-server/node_modules/typeorm/find-options/FindConditions").FindConditions<import("/Users/bracicot/dev/dev-server/packages/server-common/dist/entities/experience-post.entity").XP>' is not assignable to parameter of type 'import("/Users/bracicot/dev/dev-server/packages/server-common/node_modules/typeorm/find-options/FindConditions").FindConditions<import("/Users/bracicot/dev/dev-server/packages/server-common/dist/entities/experience-post.entity").XP>'.
Types of property 'userId' are incompatible.
Type 'string | import("/Users/bracicot/dev/dev-server/dev-server/node_modules/typeorm/find-options/FindOperator").FindOperator<string>' is not assignable to type 'string | import("/Users/bracicot/dev/dev-server/packages/server-common/node_modules/typeorm/find-options/FindOperator").FindOperator<string>'.
Type 'FindOperator<string>' is not assignable to type 'string | FindOperator<string>'.
Type 'import("/Users/bracicot/dev/dev-server/dev-server/node_modules/typeorm/find-options/FindOperator").FindOperator<string>' is not assignable to type 'import("/Users/bracicot/dev/dev-server/packages/server-common/node_modules/typeorm/find-options/FindOperator").FindOperator<string>'.
Types have separate declarations of a private property '_type'.ts(2769)
const options: FindConditions<XP>
Seems to be related to 4241 but am not sure. I'm hoping someone can help me understand this.