Skip to content

Declaration size optimisation [d.ts] #61919

Closed as not planned
Closed as not planned
@coolassassin

Description

@coolassassin

πŸ” Search Terms

declaration, d.ts, import, optimisation

βœ… Viability Checklist

⭐ Suggestion

Hello!

We are using our dependency injection library in our project (https://github.com/raveclassic/injectable-ts)
And this library allows us to describe big dependency trees
All works fine, but if I open the d.ts file, which I have as output of my library I see the huge amount of repetition:

Image

In the image, you can see that I have 3702 imports of the library, instead of importing it just once
As I understand, if we import something and not declare or export it outside, it will be just a part of the internal d.ts file logic.
If I understand correctly, this output is a result of the inferred type of the constant, but it looks possible to significantly optimise this file by importing all types once and then just reusing them

My TypeScript version: 5.3.3

πŸ“ƒ Motivating Example

Image

πŸ’» Use Cases

  1. Reduce d.ts file size
  2. Reduce compilation time based on new d.ts shape

Metadata

Metadata

Assignees

No one assigned

    Labels

    Not a DefectThis behavior is one of several equally-correct options

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions