Description
π Search Terms
"type truncation truncate compiler option "
β Viability Checklist
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
β 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
- What do you want to use this for? The ability to see complete type information even for very complex or long types
- 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.
- What workarounds are you using in the meantime? The aforementioned hack.