loopbackio / loopbackio/loopback-next
Typescript error with Model
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1.1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 27
Description
### Describe the bug
I am getting type error in find function.
```ts
@model({settings: {strict: false}})
export class URLS extends Model {
@property({
type: 'string',
id: true,
generated: true,
})
id?: string;
@property({
type: 'string',
required: true,
})
title: string;
}
@model({settings: {strict: false}})
export class Links extends Entity {
@property({
type: 'string',
id: true,
generated: true,
})
id?: string;
@property({
type: 'array',
itemType: 'object',
})
urls?: URLS[]
}
```
**Error occurring in below**
```ts
await this.linksRepository.find({
where: {
"urls.id": id
}
})
```
**Error:**
```
Type '{ "urls.id": any; }' is not assignable to type 'Where | undefined'.
Object literal may only specify known properties, and '"urls.id"' does not exist in type 'Where'.
```
### Logs
_No response_
### Additional information
_No response_
### Reproduction
NA
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the TypeScript definitions for Where and the repository find entry point used in the example, focusing on how nested array properties are represented. Confirm the intended query behavior and add regression coverage for the shown "urls.id" condition; done means the supported query type-checks without the reported error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100