microsoft / microsoft/TypeScript
Preserve radix when pretty-printing numeric literal types
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
Suggestion
🔍 Search Terms
numeric literal radix, non-decimal numeric literal types
List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback.
✅ Viability Checklist
My suggestion meets these guidelines:
- 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 feature would agree with the rest of TypeScript's Design Goals.
⭐ Suggestion
If a numeric literal type was defined explicitly with a non-decimal literal, it should be displayed as such in editor hovers and other places where it is pretty-printed.
📃 Motivating Example
Often, non-decimal literals are more-or-less self-documenting in a context:
declare const MASK: 0b1011; // it is obvious which bits are set
// vs
declare const MASK: 11; // wat?
declare const PERMISSIONS: 0o777; // unix file system permissions
// vs
declare const PERMISSIONS: 511; // wat?
declare const ARGB: 0x00ffff00; // yellow pixel color
// vs
declare const ARGB: 16776960; // wat?
declare const ASCII_CODE: 0x1b; // ASCII code for backspace
// vs
declare const ASCII_CODE: 27; // wat?
Ideally, the radix should carry over to the "autoincremented" enum members:
enum AsciiLetters {
A = 0x61, B, C, D, E, F, /* ... */, Z,
}
// AsciiLetters.E: 0x65
💻 Use Cases
Bit masks. Unix file system permissions. RGB colors. Hexadecimal ASCII/Unicode code points.
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, TypeScripts Pretty-Printing-Pfad für numerische Literaltypen und die Behandlung automatisch inkrementierter enum-Mitglieder nachzuverfolgen; das Issue nennt keine bestimmten Dateien oder Tests. Als erledigt gilt die Aufgabe, wenn Editor-Hover und andere Pretty-Printed-Ausgaben ausdrücklich geschriebene Binär-, Oktal- oder Hexadezimalbasen beibehalten, einschließlich des dargestellten enum-Falls.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100