loopbackio / loopbackio/loopback-next
TypeScript error: Property 'toString' does not exist in has-many-through.inclusion-resolver.ts after upgrading to @loopback/repository@8.0.2
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
Steps to reproduce
- Upgrade
@loopback/repositoryfrom6.1.5to8.0.2(other LoopBack packages remain at compatible versions). - Build the project with TypeScript strict mode enabled.
Current behavior
TypeScript compilation fails with:
node_modules/@loopback/repository/src/relations/has-many/has-many-through.inclusion-resolver.ts:255:36 - error TS2339: Property 'toString' does not exist on type 'NonNullable<(Target & TargetRelations)[Extract<keyof Target, string>]>'.
255 targetEntity[targetKey]?.toString() ?? targetEntity[targetKey],
node_modules/@loopback/repository/src/relations/has-many/has-many-through.inclusion-resolver.ts:269:35 - error TS2339: Property 'toString' does not exist on type 'NonNullable<(Through & ThroughRelations)[Extract<keyof Through, string>]>'.
269 x => x[throughKeyTo]?.toString() ?? x[throughKeyTo],
### Logs
```shell
```
### Additional information
_No response_
### Reproduction
import {Entity, model, property, hasMany} from '@loopback/repository'; @model() export class Category extends Entity { @property({id: true}) id: number; @hasMany(() => Product, {through: {model: () => CategoryProduct}}) products?: Product[]; } @model() export class Product extends Entity { @property({id: true}) id: number; } @model() export class CategoryProduct extends Entity { @property() categoryId: number; @property() productId: number; }
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
Open src/relations/has-many/has-many-through.inclusion-resolver.ts and inspect the expressions at lines 255 and 269 that trigger TS2339 under strict mode. Reproduce the upgrade and strict TypeScript build with the Category, Product, and CategoryProduct models; done means the build succeeds without these errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nodejs, typescript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100