Show whole truncated type in vscode & vim
I’ve been working with some fairly large types on a recent project and vscode (coc typescript with vim) will automatically truncate the type when it’s over 160 characters. This is a pretty painful deadend when inspecting a type and the workaround isn’t the simplest.
I initially tired setting the noErrorTruncation
option to true
in my tsconfig.json
as described in the accepted answer here and while this does work, it stops at 160 characters.
Turns out the solution to override this hard limit is to manually update vscode’s tsserver source code. If your running vim, find the tsserver coc is using.
For me I found this file (on a Mac) at the location /Applications/Visual\ Studio\ Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js
You’ll then want to update the ts.defaultMaximumTruncationLength
var to your wanted amount, note that the larger it is, the higher the chance of the process crashing.
~/.tsserver.js
(function (ts) {
ts.resolvingEmptyArray = [];
ts.externalHelpersModuleNameText = "tslib";
ts.defaultMaximumTruncationLength = 2000;
ts.noTruncationMaximumTruncationLength = 180;
function getDeclarationOfKind(symbol, kind) {