question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Include documentation from a variable's type when you hover the variable

See original GitHub issue

Issue Type: Feature request

I had hoped to see the description for the type when hovering over the value via intellisense, etc.

When I hover over context.slot I can see “The slot the disk is in.” yet when I try hovering over const slot I see just the type. Is there anything to enable this? Even setting slot to Slot manually it still only shows the type.

 /** The slot the disk is in. */
type Slot = string;

interface Context {
    /** The slot the disk is in. */
    slot?: Slot
}

const func = (context: Context): Context => {
    const x = context.slot;
    const slot: Slot = context.slot;

    return {
        slot: x || slot
    };
};

func({
    slot: '1'
}).slot;

VS Code version: Code 1.43.2 (0ba0ca52957102ca3527cf479571617f0de6ed50, 2020-03-24T07:34:57.037Z) OS version: Darwin x64 19.2.0

System Info
Item Value
CPUs Intel® Core™ i5 CPU M 520 @ 2.40GHz (4 x 2400)
GPU Status 2d_canvas: unavailable_software
flash_3d: disabled_software
flash_stage3d: disabled_software
flash_stage3d_baseline: disabled_software
gpu_compositing: disabled_software
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: disabled_off
rasterization: disabled_software
skia_renderer: disabled_off_ok
video_decode: disabled_software
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: unavailable_software
webgl2: unavailable_software
Load (avg) 1, 1, 2
Memory (System) 8.00GB (0.79GB free)
Process Argv .
Screen Reader no
VM 0%
Extensions (27)
Extension Author (truncated) Version
go-outliner 766 0.1.20
npm-intellisense chr 1.3.0
path-intellisense chr 1.4.2
jsrefactor cms 2.20.5
vue-peek dar 1.0.2
vscode-eslint dba 2.1.2
EditorConfig Edi 0.14.5
vscode-npm-script eg2 0.3.11
flow-for-vscode flo 1.5.0
todo-tree Gru 0.0.171
docthis joe 0.7.1
vscode-home-assistant kee 1.6.1
dotenv mik 1.0.1
vscode-docker ms- 1.0.0
csharp ms- 1.21.16
atom-keybindings ms- 3.0.6
cpptools ms- 0.27.0
Go ms- 0.13.1
vscode-typescript-next ms- 3.9.20200408
go-doc msy 0.1.1
hide-gitignored npx 1.1.0
vetur oct 0.24.0
vscode-graphql Pri 0.2.14
json-template sto 0.3.1
vscode-icons vsc 10.0.0
vscode-wakatime Wak 4.0.0
vscode-go-autotest win 1.6.0

(2 theme extensions excluded)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:5
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
mesqueebcommented, Apr 26, 2020

@RyanCavanaugh @mjbvz

Here is a real use case of mine. I have a library that uses certain types through the entire library. Sometimes as function param types, sometimes as return types, etc…

The library then exposes a set of functions the dev that uses my library must implement.

In all cases below, IF there is no extra documentation provided for wherever MyProp is used, I would like it to fall back to the documentation of MyProp:

/**
 * Documentation on MyProp I want everything below to fall back to
 */
type MyProp = string

type SomeType = {
  n: number
  myProp: MyProp
}

type AnotherType = {
  x: string
  myProp: MyProp
}

type MyTuple = [MyProp, boolean]

export type ActionDevNeedsToImplement1 = (myProp: MyProp, n: number, x: string) => void
export type ActionDevNeedsToImplement2 = (someType: SomeType) => void
export type ActionDevNeedsToImplement3 = (anotherType: AnotherType) => void
export type ActionDevNeedsToImplement4 = (myTuple: MyTuple) => void

const action1: ActionDevNeedsToImplement1 = (myProp, n, x) => {
  // ❌ no documentation when hovering over `myProp`
  // ✅ documentation when the dev writes `myProp: MyProp` in the params and hovers over MyProp instead
  
  // requirements:
  // the library creator needs to export `MyProp`
}
const action2: ActionDevNeedsToImplement2 = (someType: SomeType) => {
  // ❌ no documentation on `MyProp` when hovering over `SomeType`
  // ❌ impossible to retrieve the documentation, because:
  //    the dev only sees this when hovering over SomeType
  //    { n: number, myProp: string }
}
const action3: ActionDevNeedsToImplement3 = (anotherType: AnotherType) => {
  // same as above
}
const action4: ActionDevNeedsToImplement4 = (myTuple: MyTuple) => {
  // same as above
}

My developers are having a hard time in all the cases above to know exactly what MyProp has to represent, unless I duplicate the documentation through all types underneath MyProp.

I want to avoid this duplication of documentation issue.

This is the reason this is an important feature request by @OmgImAlexis and myself.

If there are better ways to solve my issues without adding this feature and without duplication of documentation, please advise.

2reactions
mjbvzcommented, Apr 28, 2020

Awaiting More Feedback means that we’d like feedback from more members of the community on whether this features would be useful

Read more comments on GitHub >

github_iconTop Results From Across the Web

Include documentation from a variable's type when you hover ...
I just want to add +1 to this being a feature request. IF the variable or prop of an interface is a certain...
Read more >
Display Variable Values with Text Hover - BMC Documentation
Text Hover is an additional method to display the value of variables while debugging a program. When the mouse pointer hovers over a...
Read more >
IntelliJ: Highlight the type of a variable on hover - Stack Overflow
By placing cursor on a variable and hitting Ctrl-Q you'll find all the documentation regarding this variable, including type.
Read more >
Hover over variables no longer show the debug value.
I have a problem since 24/11/2021 where in visual studio 2022 and in visual studio 2019 during a debug session the variables are...
Read more >
Cannot see variable's properties when I hover over while ...
I have my laptop connected to an external monitor via an hdmi cable. I have my display settings set to 'extend these displays'....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found