Skip to content

Idea: Can declaration emit synthesize type aliases? #44045

@amcasey

Description

@amcasey

Object types can be very large and in (e.g.) a react project that makes heavy use of type inference, it's not uncommon to have to refer to a type that is either not imported or is simply anonymous (e.g. a props type). When these appear in multiple places in a declaration file, they tend to expand it considerably. Perhaps we could just synthesize type aliases for them?

  • We'd have to be careful not to change the exported API shape
  • We could use a heuristic to skip the work for small types (e.g. < 20 characters)
  • Even if we didn't wait until the second use of a type to decide to extract it, we'd be adding ~4 tokens per type (type id = and id at the use site)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: PerformanceReports of unusually slow behaviorExperimentation NeededSomeone needs to try this out to see what happensSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions