microsoft / tsdoc

A doc comment standard for TypeScript
https://tsdoc.org/
MIT License
4.71k stars 131 forks source link

RFC: less redundant syntax #286

Open lensbart opened 3 years ago

lensbart commented 3 years ago

Hello!

First and foremost, thanks for developing this tool — looks very promising.

Proposal

When documenting my TypeScript code, I generally try to avoid redundantly retyping variable names wherever possible. For example:

// Case 1
type Input = {
  /** Description of `n` goes here */
  n: number
}

/** Description of function goes here */
export const fn = ({ n }: Input) => {
  return n ^ 2
}

// Case 2
/** Description of function goes here */
export const fn = (
  /** Description of `n` goes here */
  n: number
) => {
  return n ^ 2
}

The Description of n goes here does not currently seem to be retrieved by tsdoc. Is this something that you would consider putting on the roadmap?

I see several upsides:

Main downside:

Reference

React Styleguidist allows for a similar syntax with propTypes.