I'm attempting to do the following with Typescript and the loopback-connector-mongodb library, but get the error Object literal may only specify known properties
.
interface Foo {
likes: number;
}
// increase likes with MongoDB's '$inc'
async increaseLikes(id: string): Promise<void> {
await this.fooRepository.updateById(id, {"$inc": {likes: 1}})
}
This is a Typescript compilation error even though the code is valid Javascript.
The error can be suppressed with // @ts-ignore
interface Foo {
likes: number;
}
// increase likes with MongoDB's '$inc'
async increaseLikes(id: string): Promise<void> {
// error suppressed to allow use of MongoDB's extended operators
// @ts-ignore
await this.fooRepository.updateById(id, {$inc: {likes: 1}})
}