Anonymous Symbol Properties
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- typescript
- Bereich
- compilers
Rechercherichtung
Beginne mit den aktuellen und vorgeschlagenen Typdeklarationen im Issue und verfolge, wie TypeScript berechnete Eigenschaftsschlüssel und die Identitäten von unique symbol behandelt. Die Arbeit ist abgeschlossen, wenn inline-Schlüssel für Eigenschaften vom Typ unique symbol akzeptiert werden, jede Deklaration eine eigene Identität erhält und die Ausgabe von JavaScript zur Laufzeit erhalten bleibt; das Issue nennt keine Implementierungsdateien oder Tests.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
🔍 Search Terms
"anonymous symbol properties"
"anonymous unique symbol"
"inline unique symbol"
"unique symbol property key"
"computed property unique symbol"
"symbol branding"
✅ Viability Checklist
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ Suggestion
Allow unique symbol keys to be declared inline at the property declaration site.
📃 Motivating Example
Current code:
declare const brand: unique symbol;
type UserId = string & { readonly [brand]: "UserId" };
Proposed code:
type UserId = string & { readonly [brand: unique symbol]: "UserId" };
Each inline declaration would create a fresh symbol identity, equivalent to declaring a separate unique symbol and using it as the computed property key.
This is useful when a unique symbol property key is needed only once and does not need to be referenced independently. Common examples include phantom properties used for branded or refined types.
💻 Use Cases
-
What do you want to use this for?
Declaring single-useunique symbolproperty keys inline, particularly for phantom properties used by branded or refined types. -
What shortcomings exist with current approaches?
The current approach requires introducing a value-level declaration solely to provide a unique identity for a type-level property key. For single-use symbol keys, this creates an otherwise unnecessary binding in the surrounding scope. -
What workarounds are you using in the meantime?
Declaring a separateunique symbolvalue and using it as a computed property key.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus microsoft/TypeScript
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
microsoft/TypeScript#64322 · 2 Kommentare · 1 Reaktion · 2 zugewiesene Personen ·
-
Possible Improvement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
microsoft/TypeScript#64278 · 1 Kommentar · 1 Reaktion ·
-
Docs
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
microsoft/TypeScript#64118 · 1 Kommentar ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
microsoft/TypeScript#64094 ·
-
Docs
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
microsoft/TypeScript#63959 · 5 Kommentare ·
Alle Issues in microsoft/TypeScript
Ähnliche Issues
-
kind/bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
kubernetes-sigs/prow#953 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
caddyserver/caddy#8046 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
-
L1 recommended for recruits
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
-
optimization optimization:agents-md-curator
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
githubnext/gh-aw-cao#13143 ·