Microsoft/TypeScript

Emmited Type Declarations generate empty export

Open

#51,338 创建于 2022年10月28日

在 GitHub 查看
 (10 评论) (1 反应) (0 负责人)TypeScript (6,726 fork)batch import
BugDomain: Declaration EmitHelp Wanted

仓库指标

Star
 (48,455 star)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 9 个 PR)

描述

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.

贡献者指南