Skip to content

Emmited Type Declarations generate empty export #51338

Open
@cristobal

Description

@cristobal

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions