microsoft / microsoft/TypeScript
Try enforcing contextual type of array literal elements
Offen
Dieses Issue hat noch niemand übernommen.
Breaking Change
Committed
Suggestion
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
Part of #19236
Code
const s1: string[] = ["x", 3, null as any];
const s2: string[] = ["x", 3];
Expected behavior:
s1should be an errors2should have an error span on3
Actual behavior:
s1is not an errors2has an error span ons2, which makes it impossible to figure out which element is wrong
Hypothesis: When checking a contextually-typed array literal, if an element type isn't assignable to the contextual type, issue an error on that element and return unknownType
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
Reproduziere die beiden Array-Literal-Beispiele aus dem Issue und untersuche die kontextuelle Prüfung der Elemente von Array-Literalen durch den Compiler. Erledigt ist die Aufgabe, wenn die erste Zuweisung abgelehnt wird und die zweite den Fehler beim ungültigen Element 3 statt bei s2 meldet.
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
- 35/100