microsoft / microsoft/TypeScript
Error elaboration says nothing due to circularity
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
Bug Report
⏯ Playground Link
Playground link with relevant code
💻 Code
// @target: esnext
export interface ReadonlySparseArray<T> {
slice(start?: number, end?: number): SparseArray<T>;
every<S extends T>(
predicate: (value: T, index: number) => value is S,
): this is ReadonlySparseArray<S>;
flatMap<U>(callback: (value: T, index: number) => U | readonly U[] | ReadonlySparseArray<U>): U[];
}
export interface SparseArray<T> extends ReadonlySparseArray<T> {}
const _a: ReadonlySparseArray<string> = ['a'];
const _b: SparseArray<string> = ['a'];
🙁 Actual behavior
_b:
Type 'string[]' is not assignable to type 'SparseArray<string>'.
Types of property 'slice' are incompatible.
Type '(start?: number | undefined, end?: number | undefined) => string[]' is not assignable to type '(start?: number | undefined, end?: number | undefined) => SparseArray<string>'.ts(2322)
In trying to tell you why string[] is not assignable to SparseArray<string>, the elaboration references two signatures which are identical except for their return types: string[] and SparseArray<string>, which lands you right back where you started.
This particular example occurs in #50351, which is a separately buggy behavior, so this repro may stop reproing if that gets fixed.
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
Inizia con l’esempio collegato di TypeScript Playground e confronta la diagnostica per l’assegnazione _b con il comportamento descritto nell’issue. Leggi la discussione correlata in #50351 per comprendere la dipendenza separata della riproduzione. Il lavoro è completato quando l’elaborazione dell’errore non torna più al confronto di assegnabilità originale né fornisce una spiegazione circolare non utile.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100