microsoft / microsoft/TypeScript
Too wide diagnostic with array spread
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
🔎 Search Terms
array spread, diagnostics
🕗 Version & Regression Information
- This is the behavior in every version I tried and I have reviewed the FAQ
⏯ Playground Link
💻 Code
type Abc = "a" | "b" | "c";
const array1: Abc[] = ["a", "b"];
const array2: Abc[] = [
...array1,
"a",
"b",
"d",
]
🙁 Actual behavior
The whole contents of array2 is highlighted in red.
🙂 Expected behavior
Only the "d" should be highlighted in red, as it is the only incorrect part of array2. Note that if we remove the spread ...array1, then it works as expected.
Additional information about the issue
With more complicated types/data, this bug can make it pretty hard to diagnose where the problem is.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der verknüpften TypeScript Playground-Reproduktion und dem Array-Spread-Beispiel im Issue. Verfolge, wie die Diagnosen für das Array-Literal erzeugt werden, und überprüfe anschließend, dass nur das Element "d" hervorgehoben wird, während der Spread und die gültigen Elemente nicht hervorgehoben werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 38/100