Microsoft/TypeScript

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

Open

#52.730 aperta il 12 feb 2023

Vedi su GitHub
 (0 commenti) (3 reazioni) (0 assegnatari)TypeScript (6726 fork)batch import
Domain: LS: Completion ListsExperience EnhancementHelp WantedSuggestion

Metriche repository

Star
 (48.455 star)
Metriche merge PR
 (Merge medio 6g 17h) (9 PR mergiate in 30 g)

Descrizione

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

Guida contributor