microsoft / microsoft/TypeScript
Adding documentation comments to the return values of destructuring syntax
Nobody has claimed this yet.
- 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
stateXwith 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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