microsoft / microsoft/TypeScript
Docs: "Type assertion" vs "asserts" keyword
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
Hey there!
I’m updating Programming TypeScript to include assertions in control flow analysis, and was looking for guidance about naming.
Type assertions (x as T) and assertions in control flow analysis (asserts x is T) are similarly named. What’s a good way to call these these features, in a way that doesn’t confuse people and aligns with the way the TS team is communicating it?
A couple of ideas:
- Rename
x as Tto “type coercion” or “type casting" (even though it’s not a runtime behavior), and callasserts x is Ta “type assertion” - Keep
x as Tas-is (“type assertion”), and callasserts x is Ta “user-defined type assertion”, similar to a “user-defined type guard”
Thanks!
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 damit, den verknüpften Pull Request 32695 und die Diskussion des Issues über x as T im Vergleich zu asserts x is T zu prüfen. Als erledigt gilt, wenn eine vereinbarte Namenskonvention erreicht wurde, die mit der Kommunikation von TypeScript übereinstimmt und die Aktualisierung von Programming TypeScript anleiten kann.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- documentation
- Issue-Typ
- Dokumentation
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100