Repository: TypeScript
Issue: Preserve radix when pretty-printing numeric literal types
Labels: Suggestion,Awaiting More Feedback,Domain: Declaration Emit,Domain: Type Display

# Suggestion

<!--
  Please fill in each section completely. Thank you!
-->

## 🔍 Search Terms

numeric literal radix, non-decimal numeric literal types

<!--
  💡 Did you know? TypeScript has over 2,000 open suggestions!
  🔎 Please search thoroughly before logging new feature requests as most common ideas already have a proposal in progress.
  The "Common Feature Requests" section of the FAQ lists many popular requests: https://github.com/Microsoft/TypeScript/wiki/FAQ#common-feature-requests

  Replace the text below:
-->

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

<!--
   Suggestions that don't meet all these criteria are very, very unlikely to be accepted.
   We always recommend reviewing the TypeScript design goals before investing time writing
   a proposal for ideas outside the scope of the project.
-->
My suggestion meets these guidelines:

* [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code
* [x] This wouldn't change the runtime behavior of existing JavaScript code
* [x] This could be implemented without emitting different JS based on the types of the expressions
* [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).


## ⭐ Suggestion

<!-- A summary of what you'd like to see added or changed -->

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

<!--
  If you were announcing this feature in a blog post, what's a short explanation that shows
  a developer why this feature improves the language?
-->

Often, non-decimal literals are more-or-less self-documenting in a context:

```typescript
declare const MASK: 0b1011; // it is obvious which bits are set
// vs
declare const MASK: 11; // wat?
```

```typescript
declare const PERMISSIONS: 0o777; // unix file system permissions
// vs
declare const PERMISSIONS: 511; // wat?
```

```typescript
declare const ARGB: 0x00ffff00; // yellow pixel color
// vs
declare const ARGB: 16776960; // wat?
```

```typescript
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:

```typescript
enum AsciiLetters {
  A = 0x61, B, C, D, E, F,  /* ... */, Z,
}
// AsciiLetters.E: 0x65
```

## 💻 Use Cases

<!--
  What do you want to use this for?
  What shortcomings exist with current approaches?
  What workarounds are you using in the meantime?
-->

Bit masks. Unix file system permissions. RGB colors. Hexadecimal ASCII/Unicode code points.