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
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 5.1k
- Fork
- 1.1k
- Merge medio
- 2g 21h
- PR unite (30g)
- 27
Descrizione
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; }
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Apri src/relations/has-many/has-many-through.inclusion-resolver.ts e analizza le espressioni alle righe 255 e 269 che attivano TS2339 in strict mode. Riproduci l'upgrade e la build TypeScript strict con i modelli Category, Product e CategoryProduct; l'attività è completata quando la build riesce senza questi errori.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- nodejs, typescript
- Ambito
- backend
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 42/100