Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

The Jared Wilcurt
The Jared Wilcurt

Posted on

     

TS is bad at hover text

A literal angel (AngelCMHxD), made a PR against one of my repos to add a.d.ts definition file for both auto-complete, and hover text. This is what happened next...


After testing his PR locally with the TypeScript.d.ts file, the result was this:

Unreadable TypeScript Garbage

Note that I'm hovering over thewindows key and it is not giving me any valuable information. It provides the same truncated mess of text (that is hard to visually parse), as when you hover overcreateDesktopShortcuts.


The repo was already written with JSDocs enforced everywhere via a simple linting plugin (use it, it's very good). In comparison, JSDocs provides identical type support as what TS does, and far better hints.


With JSDocs, we get a cleaner hover:

top level JSDocs hover

And on hover of thewindows key, we get much better context, explaining that it requires afilePath string.

Next level JSDocs hover


Ultimately, there was no way to get TS to generate a usable hover tooltip. Their official recommendation is to use JSDocs.

Because the TypeScript Engine and Compiler work exactly the same with types defined in JSDocs as they do with types written in the TypeScript syntax, my library does not use any TypeScript at all, but is fully typed and fully TS compatible.

Top comments(1)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
aakarshchopra profile image
Aakarsh Chopra
Coding - Designing - Petting Dogs
  • Location
    Chennai, India
  • Education
    Undergraduate in Engineering
  • Joined

TS documentation in hover tooltips does seem a scrambled egg, but IMO it can still more helpful than not having anything at all

Apart from using JSDoc, the best work-around I know of is this VSCode extension:Pretty TS Errors

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Cross-Platform Desktop App (XPDA) Engineer, Senior Frontend Web Developer. Maintainer of Scout-App. Editor of XPDA.net.
  • Location
    Indianapolis, IN
  • Joined

More fromThe Jared Wilcurt

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp