RFC: less redundant syntax
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5k
- Forks
- 162
- Avg merge
- 17h 24m
- Merged PRs (30d)
- 8
Description
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:
- The parameter description is colocated with its name and type for easier visual grepping
- It is not needed to retype the variable name anymore, avoiding potential mismatch when refactoring
@paramcan be left out, so less verbose (but equally clear) syntax- Works especially well (is visually pleasing) for functions with a destructured object as argument, cf.
Case 1above
Main downside:
- Function declaration with non-destructured argument(s) (cf. Case 2 above) gets a bit more clumsy for large comment blocks, which may look unfamiliar. Therefore I would propose to keep this as an optional (and perhaps recommended) extension to the current way of working, and not as a replacement.
Reference
React Styleguidist allows for a similar syntax with propTypes.
Contributor guide
No contributing guide indexed for this repository
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
No repository files, tests, or entry points are named. Start with the proposal's TypeScript examples and the React Styleguidist reference; done would mean deciding whether colocated parameter comments belong on the TSDoc roadmap and documenting the resulting direction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- documentation
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100