Microsoft/TypeScript

Emmited Type Declarations generate empty export

Open

#51 338 ouverte le 28 oct. 2022

Voir sur GitHub
 (10 commentaires) (1 réaction) (0 assignés)TypeScript (6 726 forks)batch import
BugDomain: Declaration EmitHelp Wanted

Métriques du dépôt

Stars
 (48 455 stars)
Métriques de merge PR
 (Merge moyen 6j 17h) (9 PRs mergées en 30 j)

Description

Bug Report

When generating type declaration files if a type that is only used inside the typescript code however it is not exported results in an empty export at the end of the file e.g. export {};

🔎 Search Terms

  • declaration empty export
  • declaration "export {}"

🕗 Version & Regression Information

When i started inspecting the generated typescript declarations generated. I see the same error/behaviour when either typescript@4.8 and typescript@next

This is the behavior in every version I tried, and I reviewed the FAQ for entries about emmited code and private fields and methods.

⏯ Playground Link

  • When some of the types are not exported this happens playground example here
  • When all of the types are exported there is no empty export playground example here

💻 Code

Empty Export Code

type TaskType = 'ONE' | 'TWO' | 'THREE';

// would not expected to have an empty export 
// in the emitted type declaration code here is this correct?
export interface Task {
  executeTask(type:TaskType):void;
}

No Empty Export

// no empty export since all types and interfaces exported
export type TaskType = 'ONE' | 'TWO' | 'THREE';
export interface Task {
  executeTask(type:TaskType):void;
}

🙁 Actual behavior

Empty export for some reason…

🙂 Expected behavior

No default empty export.

Guide contributeur