You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Setting noErrorTruncation to false truncates inferred type of variables/functions; which are not errors #26238
In TS 2.9, if noErrorTruncation is unset, or set to false, hovering the cursor over an identifier for type inference in VS code would bring up a tooltip with the inferred type.
In TS 3.0, if noErrorTruncation is unset, or set to false, the tooltip with the inferred type will be truncated with ellipsis.
Weird. I thought I finally "fixed" it but, even with noErrorTruncation turned on, some long and complicated types still show up with ellipsis.
Is there a noInferredTypeTruncation thing I'm missing?
Turning on noErrorTruncation certainly stops some truncations, but it still doesn't prevent others.
Reacted by Tomasz Waszczyk, Kael, Anthony Giniers, Kotaro Sugawara, Jason Rogers, Keegan Farley, Cam McKinnon, Ivan Wang, Hugh Collins, Kirill Hmelnitski and 25 more
one solution (that are not fast on the project that i works, because needs to load a bunch of things, but works very well) is the extension ts type expand.
I just wanted to call out that if your VSCode config specifies the "typescript.tsdk" option, you'll need to update the tsserver.ts in whatever location that option specifies. It would have saved me a bit of debugging time 🙃
A little more context that I think is worth sharing... setting noErrorTruncation to true can cause some significant performance implications with errors.
I just spent 20 minutes trying to figure out why an error was popping up in my console but not inline where the error was... went over to GitHub to comment on a few things and let it sit and the error finally popped up and it clicked 🙃
I'm definitely keeping it set to true for usability but now have to remember that it can cause debugging issues with really complicated types ☹️
I just wanted to call out that if your VSCode config specifies the "typescript.tsdk" option, you'll need to update the tsserver.ts in whatever location that option specifies. It would have saved me a bit of debugging time 🙃
Thank you for saying this because you saved me a lot of time! Slight correction, though: it's named tsserver.js
If for nothing else, I thought this was worth reporting for the irony: in my case, the ... was truncating a three character number.
Reacted by Kael, Rodger Benham, Charles Esterbrook, Nathan Dassardo-Joseph, Beni Cherniavsky-Paskin, Chris Marx, Florent Garit, yuDouble, li4man0v, Damien Golding and 4 more
Reacted by D Bersan
Reacted by Ivens Joris, Chris Marx, kukeiko, Armando Garcia, Dmitry and Yiling Wang
For me, the path name has spaces in it which was upsetting the sed command (I couldn't work out why), so with the help of chatGPT I managed to refactor it to use awk. Sharing here for others:
#!/bin/bash
if [ $# -lt 1 ]; then
echo "Usage: $0 <directory_path> <new_length>?"
exit 1
fi
directory_path="$1"
new_length="$2"
if [ -z "$2" ]
then
echo "No length supplied, will use default (160)"
new_length=160
fi
file_path=$(find "$directory_path" -name "tsserver.js" 2>/dev/null)
if [ -z "$file_path" ]; then
echo "tsserver.js file not found within directory $directory_path after recursive search"
exit 1
fi
echo "Found tsserver.js at \"$file_path\""
# Use awk to perform the replacement
awk -v new_length="$new_length" '{sub(/var defaultMaximumTruncationLength = [0-9]+;/, "var defaultMaximumTruncationLength = " new_length ";")}1' "$file_path" > temp_file && mv temp_file "$file_path"
echo "Length updated successfully: "
cat "$file_path" | grep "defaultMaximumTruncationLength = "
Reacted by Mathias Malmqvist, Tatsh and Dave Jones
For me, the path name has spaces in it which was upsetting the sed command (I couldn't work out why), so with the help of chatGPT I managed to refactor it to use awk. Sharing here for others:
#!/bin/bash
if [ $# -lt 1 ]; then
echo "Usage: $0 <directory_path> <new_length>?"
exit 1
fi
directory_path="$1"
new_length="$2"
if [ -z "$2" ]
then
echo "No length supplied, will use default (160)"
new_length=160
fi
file_path=$(find "$directory_path" -name "tsserver.js" 2>/dev/null)
if [ -z "$file_path" ]; then
echo "tsserver.js file not found within directory $directory_path after recursive search"
exit 1
fi
echo "Found tsserver.js at \"$file_path\""
# Use awk to perform the replacement
awk -v new_length="$new_length" '{sub(/var defaultMaximumTruncationLength = [0-9]+;/, "var defaultMaximumTruncationLength = " new_length ";")}1' "$file_path" > temp_file && mv temp_file "$file_path"
echo "Length updated successfully: "
cat "$file_path" | grep "defaultMaximumTruncationLength = "
Minor thing on the last line: grep "defaultMaximumTruncationLength = " "$file_path" will also work.
Just to point out, I made this change on my windows install of VS code, I set defaultMaximumTruncationLength=800 and it seem that the change was reverted recently.
What I don't understand is why typeToString is not respecting the noErrorTruncation compiler option.
something about const noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */; is causing it to get ignored
noTruncationMaximumTruncationLength is set to 1e6 so this should not be an issue. I have to assume that when vscode is calling the typeToString function, the flag value is causing the compiler option to be ignored.
This extension simply doesn't solve the issue. You still need to manually click through this overly complex search tree. I just wanna see the full type, as plain string
Also for anyone interested, until we have an inbuilt fix/alternative, I did find another extension you can use on vscode that expands the entire (or set length and depth) of the type when you hover over it (similar to vscode hover functionality)
will occasionally reset the defaultMaximunTruncationLength values in these .js files, which will require you to manually update them again.
Also the most recent version of vscode's appears to sometimes ignore these values, even when set (even after reloading/restarting the server). At least that's what I was experiencing. Using this extension resolved things for me though
Reacted by Eric Moore, ahmad baddah, owen, Kyle Weintraub, Mario Carbajal, Noah Sherwin, caly-amigo and Yunji Lee
Activity
AnyhowStep commentedon Aug 8, 2018
Weird. I thought I finally "fixed" it but, even with
noErrorTruncationturned on, some long and complicated types still show up with ellipsis.Is there a
noInferredTypeTruncationthing I'm missing?Turning on
noErrorTruncationcertainly stops some truncations, but it still doesn't prevent others.TomaszWaszczyk commentedon Feb 5, 2019
The same for me. TypeScript 3.2.2
AnyhowStep commentedon Feb 7, 2019
I'm pretty sure it has something to do with
createElidedInformationPlaceholder17 remaining items
vensauro commentedon Dec 22, 2022
one solution (that are not fast on the project that i works, because needs to load a bunch of things, but works very well) is the extension ts type expand.
https://github.com/d-kimuson/ts-type-expand

JohnGemstone commentedon Feb 26, 2023
Thank you!
SpencerKaiser commentedon Apr 5, 2023
A little more context that I think is worth sharing... setting
noErrorTruncationtotruecan cause some significant performance implications with errors.I just spent 20 minutes trying to figure out why an error was popping up in my console but not inline where the error was... went over to GitHub to comment on a few things and let it sit and the error finally popped up and it clicked 🙃
I'm definitely keeping it set to☹️
truefor usability but now have to remember that it can cause debugging issues with really complicated typesDanKaplanSES commentedon Apr 22, 2023
Thank you for saying this because you saved me a lot of time! Slight correction, though: it's named
tsserver.jsIf for nothing else, I thought this was worth reporting for the irony: in my case, the
...was truncating a three character number.Ivens Joris (@vensauro) That extension doesn't seem to work anymore. Shame, because it looks really useful.
nikelborm commentedon Apr 22, 2023
There is one awesome extension that is just enormously cool. It allows to explore "compiled" versions of very complex types
It allows to explore not only types and interfaces, but literally anything: vars, functions, classes, promises, generics
Name: TypeScript Explorer
Id: mxsdev.typescript-explorer
Description: Full type information for variables, components, functions, and more in TypeScript projects!
Version: 0.4.0
Publisher: mxs
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=mxsdev.typescript-explorer
zetdotdev commentedon May 31, 2023
Thanks for the hack Hati (@Hati-),
Another gotcha I found is that if you're using VSCode on the WSL2, your tsserver.js is located here:
~/.vscode-server/bin/*SOME_HASH_HERE*/extensions/node_modules/typescript/lib/tsserver.jsHere's a quick bash script I use to quickly switch back and forth to avoid any performance issues with high values on the truncation:
Executing it with just the dir will result in resetting it to the default value of 160:
changeTypescriptHintLength.sh ~/.vscode-serverExecuting it with a second argument will change it
changeTypescriptHintLength.sh ~/.vscode-server 800Note: restarting the TS server is enough for the changes to take effect, no need to restart the entire VSCode.
blackhaj commentedon Sep 4, 2023
This is awesome Zetxus - thanks so much!
For me, the path name has spaces in it which was upsetting the sed command (I couldn't work out why), so with the help of chatGPT I managed to refactor it to use awk. Sharing here for others:
Tatsh commentedon Sep 6, 2023
Minor thing on the last line:
grep "defaultMaximumTruncationLength = " "$file_path"will also work.Djones4822 commentedon Sep 16, 2023
Just to point out, I made this change on my windows install of VS code, I set defaultMaximumTruncationLength=800 and it seem that the change was reverted recently.
What I don't understand is why typeToString is not respecting the noErrorTruncation compiler option.
something about
const noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */;is causing it to get ignorednoTruncationMaximumTruncationLengthis set to 1e6 so this should not be an issue. I have to assume that when vscode is calling the typeToString function, the flag value is causing the compiler option to be ignored.devcaeg commentedon Jul 17, 2024
It seems that in recent versions the "defaultMaximumTruncationLength" option is no longer present in the "tsserver.js" file.
Where is this option currently available, or where can I increase this value?
dbersan commentedon Jul 30, 2024
This extension simply doesn't solve the issue. You still need to manually click through this overly complex search tree. I just wanna see the full type, as plain string
MilesWellsSVT commentedon Jul 30, 2024
Same directory, but now in
typescript.jsaasmal97 commentedon Jul 31, 2024
Also for anyone interested, until we have an inbuilt fix/alternative, I did find another extension you can use on vscode that expands the entire (or set length and depth) of the type when you hover over it (similar to vscode hover functionality)
This is the extension:
https://marketplace.visualstudio.com/items?itemName=MylesMurphy.prettify-ts
I went this route since currently,
will occasionally reset the
defaultMaximunTruncationLengthvalues in these.jsfiles, which will require you to manually update them again.Also the most recent version of vscode's appears to sometimes ignore these values, even when set (even after reloading/restarting the server). At least that's what I was experiencing. Using this extension resolved things for me though