microsoft / microsoft/TypeScript

Compiler Option typeTruncationLength

Open
#59,035 5 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

🔍 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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the issue's description of noErrorTruncation, the tsserver.js workaround, and the linked TypeScript Playground example to understand the differing hover behavior. Trace where the proposed tsconfig option would apply across compiler and language-service output, then define tests for the default limit, a custom character count, and 0 disabling truncation.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.