microsoft / microsoft/TypeScript

Adding documentation comments to the return values of destructuring syntax

Open
#60,759 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Type: Feature Request

  • In ReactJS, we often write code similar to const [stateX, setStateX] = useState({ ... });.

  • I would like to hover over the variable name stateX with the mouse in other places where this variable is used to get an explanation similar to JSDoc (not for type, but to more clearly annotate the purpose of the variable).

  • The reason I think this way is because the following approach often works:

/** It's a ref for X */
const refX = useRef({ ... });

(When I hover over the refX variable in other places where it is accessed, the tooltip can display the documentation "It's a ref for X".)

  • However, I have not found any way to annotate without disrupting the original code structure, so that VSCode can recognize my documentary comments for the tuple.
  • I'm not sure whether this should be considered a feature request or a bug report.

VS Code version: Code 1.95.3 (Universal) (f1a4fb101478ce6ec82fe9627c43efbf9e98c813, 2024-11-13T14:50:04.152Z)
OS version: Darwin arm64 22.3.0
Modes:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported TypeScript destructuring example in VS Code and compare its hover behavior with the documented useRef example. Trace the language-service behavior responsible for hover documentation and determine whether tuple bindings can expose separate comments; done means the requested variable documentation appears without changing the original code structure.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.