Reputation: 46683
In VSCode, TypeScript shows really useful expansions of types I define. But there's a limit to what TS will show in IntelliSense. If a type is too long, then I'll see output like this:
Note the "11 more" near the end. Sometimes, for troubleshooting a difficult type definition, it's really helpful to see what's in that "N more" section.
Is there a way to get ahold of (for troubleshooting purposes during development) the fully-expanded type definition, without those "N more" messages to hide what's inside?
https://github.com/Microsoft/vscode/issues/6638 implies that this capability might not have been available (nor planned) as of Feb 2017, but I'm not sure I'm reading that issue correctly and regardless things may have changed in the meantime.
Upvotes: 109
Views: 32447
Reputation: 50284
VS Code added an extension API for selecting verbosity levels in hovers (see #195394).
TypeScript's issue ticket for supporting this feature / integrating with this feature is in issue ticket Support Expandable Quick Info/Hover Verbosity #59029.
This is available as an experimental, opt-in feature in VS Code 1.96, with the setting "typescript.experimental.expandableHover": true
.
Upvotes: 4
Reputation: 1647
The accepted answer works for cases where the length of the type's description is 1600 characters or less.
To go beyond this hard limit, it's necessary to tweak the source code, as described in this fix posted on GitHub.
UPDATE: as of 2024-10-28, the location of the line to change is:
/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typescript.js
Where /Applications/Visual Studio Code.app
is the default installation path on Mac—swap it out with where Visual Studio Code is installed on your system.
The line to change now looks like:
var defaultMaximumTruncationLength = 160;
and appears on line 16057.
Per @Denis-P, the new limit becomes 2X the value you set rather than 10X as before.
Once you've made the change, run command: >Developer: reload window for it to take effect.
Upvotes: 32
Reputation: 12095
In the next line you can write:
type SubType = TransformArray['']
Put cursor inside the ''
and VS-Code should display more helpful popover.
Upvotes: 5
Reputation: 30899
Try setting the noErrorTruncation
option to true in tsconfig.json
. Confusingly enough, this option affects truncation of types displayed on hover in at least some circumstances; see this issue. Be careful: if your type is really huge, VS Code may hang when you try to view it.
Upvotes: 125