microsoft / microsoft/TypeScript

Symbol properties should not be exempt from excess property checks in presence of a string index signature

Offen
#44,794 4 Kommentare 2 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@ahejlsberg arbeitet bereits daran.

Seit 28.6.2021.

Breaking Change Bug Domain: check: Excess Property Checking Rescheduled
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.4k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

In #44793, we found that a symbol index signature doesn't turn off excess property checks on symbols; however, a string index signature turns these excess property checks entirely.

interface A {
    a?: string
    b?: number
    [key: string]: unknown
}

const symbolKey = Symbol('key')

const a: A = {
    [symbolKey]: '123', // works!
}

It's likely that some users relied on this behavior; however, those users will be able to use symbol index signatures in TypeScript 4.4.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.