microsoft / microsoft/TypeScript
Index signature is assignable to weak type whose properties don't match the signature type
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
From https://stackoverflow.com/q/52368008 . Based on https://github.com/Microsoft/TypeScript/pull/16047#issue-122101801, it appears that @sandersn may have thought about the rule, but it still makes no sense to me and no rationale is stated.
TypeScript Version: master (394ee31a56c40033f31a3a8461ec267463033194)
Search Terms: weak type index signature
Code
interface Foo {
a?: string;
}
interface Bar {
[n: string]: number;
}
declare let b: Bar;
// No error; expected "Type 'Bar' has no properties in common with type 'Foo'."
let a: Foo = b;
Expected behavior: Error: "Type 'Bar' has no properties in common with type 'Foo'."
Actual behavior: No error.
Playground Link: link
Related Issues: Possibly #9900
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 Reproduktion im TypeScript Playground und vergleiche das aktuelle Ergebnis mit der erwarteten Diagnose für schwache Typen. Lies die Diskussion in Issue #9900 und Pull Request #16047, um die bestehende Regel und ihre Begründung zu verstehen. Erledigt ist die Aufgabe, wenn das Beispiel den angegebenen Fehler meldet, ohne verwandte Zuweisungen an Index-Signaturen zu beeinträchtigen.
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
- Ruhig
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 52/100