How to see a fully-expanded TypeScript type without "N more" and "..."?

Viewed 7665

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:

enter image description here

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.

3 Answers

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 change ts.defaultMaximumTruncationLength = 160 at around line 12797 to something higher like ts.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.)

In the next line you can write:

type SubType = TransformArray['']

Put cursor inside the '' and VS-Code should display more helpful popover.

Related