Repository: TypeScript
Issue: Preserve interfaces in generated declaration files for augmentation
Labels: Needs Investigation

# Suggestion

<!--
  Please fill in each section completely. Thank you!
-->

#### 2023 Updat

We investigated this, and turns out its easy to workaround, just extract function's type into standalone type declaration. So its low priority for us now.

## 🔍 Search Terms

Stop emitting never for empty interfaces from declaration

<!--
  💡 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:
-->

## ✅ 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

Make TypeScript compiler preserve references to original Interfaces. (or at very least add an option for this!)

<!-- A summary of what you'd like to see added or changed -->

## 📃 Motivating Example

[Playgroud link](https://www.typescriptlang.org/play?#code/KYDwDg9gTgLgBASwHY2FAZgQwMbDgSRTS1wBUIBBAVwHMBbYFOAbwCg4O5WBfV10SLDgATYFioAbeAB5ScUKiTCAznADWwAJ4R0BIhhzBy1eoxgA+ABQbNALjikANHABumCVWD3CqA2Uq0DCgA2qQAugCUcAC85ixw3ADcQA)
<!--
  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?
-->

```ts
export interface InterfaceToAugment {

}

export default <T extends keyof InterfaceToAugment>(key: T, value: InterfaceToAugment[T]) => { };
```
After we run `tsc` (with `declaration: true` of course) we'll see our `.d.ts` file:
```ts
export interface InterfaceToAugment {
}
declare const _default: <T extends never>(key: T, value: InterfaceToAugment[T]) => void;
export default _default;
```
As you can see here, declaration file making this interface absolutely useless., but I wanted to make this function to pick **real keys** of this interface.

Is there any workaround for this?

## 💻 Use Cases

Module Augmentation for library consumer

```ts
declare module "this-lib" {
  interface InterfaceToAugment {
    myCustomKey: 5
  }
}
```

<!--
  What do you want to use this for?
  What shortcomings exist with current approaches?
  What workarounds are you using in the meantime?
-->

---
Please, correct me if I missed something