Skip to content

Compiler Option typeTruncationLengthΒ #59035

Open
@HardworkingSlacker

Description

@HardworkingSlacker

πŸ” Search Terms

"type truncation truncate compiler option "

βœ… Viability Checklist

⭐ Suggestion

New Compiler Option for tsconfig: typeTruncationLength: number
The specified number is the amount of characters that will be shown before an ellipsis cutoff happens.
set to 1600 characters by default.
special value 0 means truncation is disabled completely.

πŸ“ƒ Motivating Example

I need type information to know what I am working with, especially when working with mapped or infered Types.
Preferably, I hover over the type or variable I want to inspect in visual studio code (or typescript playground).
This information inevitably gets truncated when it exceeds the built-in character limit of effectively 1600, even when setting noErrorTruncation to true (which shouldn't affect type information yet it does, see #26238)
You can manually adjust that limit by hacking tsserver.js in your vscode install location (reference).

I think that being able to receive complete type information in a language that's entire purpose is to add said thing to javascript is a core requirement.

This code example might help exemplify the issue (switch noErrorTruncation on/off to see the different behaviors for onhover truncation).

πŸ’» Use Cases

  1. What do you want to use this for? The ability to see complete type information even for very complex or long types
  2. What shortcomings exist with current approaches? Partial information entails extensive backtracking to the original interfaces/type definitions to see all fields and their types or intentionally causing type errors to see full information.
  3. What workarounds are you using in the meantime? The aforementioned hack.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions