microsoft / microsoft/TypeScript

Show jsdoc for `keyof` when used as a parameter.

Open
#52,730 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Domain: LS: Completion Lists Experience Enhancement Help Wanted Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Suggestion

🔍 Search Terms

  • keyof jsdoc
  • "keyof jsdoc"

✅ Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

When using keyof as a parameter for a function and the key has jsdoc, it would be nice if the jsdoc would show with the completion item in the editor. Currently it only shows the the item and no description of the item.

📃 Motivating Example

export interface ExampleInterface {
  /** Description of example 1. */
  example_one: string;
  /** Description of example 2. */
  example_two: string;
}

function example(usage: keyof ExampleInterface) {
  // Do something
}

// Show description of item in editor (`|` represents the cursor).
example('example_t|')

💻 Use Cases

With a library, the user may not know what the values mean without doing research. It would help if they could see the jsdoc for the item.

As seen here where something such as _ansestor has a meaning that someone may not know what it means without doing a web search.

image

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

No implementation file or test is named. Start by tracing editor completion handling for a keyof parameter using the motivating TypeScript example, then identify the relevant completion tests. Done means completion items for keys of ExampleInterface include their property JSDoc descriptions.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.