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.
Visual Studio Code IntelliSense is provided for JavaScript, TypeScript, JSON, HTML, CSS, SCSS, and Less out of the box. VS Code supports word based completions for any programming language but can also be configured to have richer IntelliSense by installing a language extension.
IntelliSense shows you intelligent code completion, hover information, and signature help so that you can write code more quickly and correctly. VS Code provides IntelliSense for individual TypeScript files as well as TypeScript tsconfig. json projects.
The -g means it's installed on your system globally so that the TypeScript compiler can be used in any of your projects. Test that the TypeScript is installed correctly by typing tsc -v into your terminal or command prompt. You should see the TypeScript version print out to the screen.
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.
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.
To quote:
For people using VS Code, a quick fix would be opening
<Microsoft VS Code install folder>/resources/app/extensions/node_modules/typescript/lib/tsserver.js
and changets.defaultMaximumTruncationLength = 160
at around line 12797 to something higher likets.defaultMaximumTruncationLength = 800
.
Once you've made the change, close and restart VSCode to get the intended effect.
(The new hard limit will be 10 * whatever value you set.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With