Repository: TypeScript
Issue: export default: support inlined unique symbol
Labels: Suggestion,Awaiting More Feedback,Domain: Declaration Emit

# Suggestion

<!--
  Please fill in each section completely. Thank you!
-->

## 🔍 Search Terms

<!--
  💡 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:
-->

- export default
- unique symbol

## ✅ 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 -->

Make `export default Symbol()` emit type declarations for a `unique symbol` instead of simply a `symbol`.

## 📃 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?
-->

export unique symbol as default without needing to declare it separately first

## 💻 Use Cases

<!--
  What do you want to use this for?
  What shortcomings exist with current approaches?
  What workarounds are you using in the meantime?
-->

I'm building a library that exports various symbols for use but I found that in order to use them as unique symbols that I have to declare them separately from exporting them. This isn't required for JavaScript at runtime and I'd like to be able to not need to name my symbol before exporting.

e.g.

```ts
export default Symbol();
```

emits

```d.ts
declare const _default: symbol;
export default _default;
```

and when used as a property name results in an error:

```console
A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type.ts(1169)
```

while

```ts
const symbol = Symbol();
export default symbol;
```

emits

```d.ts
declare const symbol: unique symbol;
export default symbol;
```

and works as expected as a property name

it's a small thing but if TypeScript could infer the type as the type of the default export of the module that'd be helpful and wouldn't cause writing the code differently to get correct typing