loopbackio / loopbackio/loopback-next
[@loopback/sequelize] Typescript error when using the "required" property with Sequelize
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
When trying to use the new "required: true" to use an Inner Join instead of a Left Join, it leads to a Typescript error:
```
Type '{ relation: string; scope: { where: { id: number; }; }; required: true; }'
is not assignable to type 'InclusionFilter'.
Object literal may only specify known properties, and 'required'
does not exist in type 'Inclusion'.
53 required: true
```
This also happens for nested relation operations such as:
```
myRepository(foreignKey).find({
include: [
{
// ...
required: true
}
]
}
```
### Logs
_No response_
### Additional information

### Reproduction
https://codesandbox.io/p/devbox/loopback-sequelize-types-24l36w
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 with the linked CodeSandbox reproduction and inspect the InclusionFilter and Inclusion types involved in the TypeScript error. Confirm how the Sequelize extension represents nested includes, then verify that required: true is accepted and the reproduction compiles for both relation operations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100