sublimelsp / LSP-typescript

TypeScript, JavaScript support for Sublime LSP plugin
MIT License
134 stars 11 forks source link

Full type definition #213

Closed dportalesr closed 1 year ago

dportalesr commented 1 year ago

When inspecting a type with a long definition, the tooltip triggered by hovering shows basically only a preview of it.

LSP-typescript 🔊-20230518-000603

In my case, "Go to type definition" is not very helpful since my type is an union of other unions which definitions could reside in multiple files.

Is there a way to enable or get (even using other method) the full details of the resolved type? That is, showing the whole list of fields instead of showing "..." or "... n more..."

Thanks in advance!

rchl commented 1 year ago

Maybe try with https://www.typescriptlang.org/tsconfig#noErrorTruncation enabled in tsconfig.json.

Note that I've seen reports of this option making type checking a lot slower so probably best to only use it when debugging.

dportalesr commented 1 year ago

Unfortunately, that didn't work. I also tried with both tsserver.logVerbosity and tsserver.trace settings but no luck whatsoever.

rchl commented 1 year ago

Can you provide code sample or project that reproduces?

Note that this is not something that this server would have to support anyway. It's all coming from TypeScript itself.

Personally I've used this snippet that I found on StackOverflow somewhere for cases like this: https://gist.github.com/rchl/9ca0a2bdc95f2c36c4d590572a4d038c (you'd need to modify the code of the type of course).

dportalesr commented 1 year ago

It seems to happen with inferred types: https://github.com/microsoft/TypeScript/issues/38557 https://github.com/microsoft/TypeScript/issues/26238

Not an ideal solution but I solved it by changing defaultMaximumTruncationLength = 160 to defaultMaximumTruncationLength = 16000 in tsserver.js as described here, except that since I'm using SublimeText the file I needed to modify was at myProjectRoot/node_modules/typescript/lib/tsserver.js

Thanks for the help!