Skip to content

The right way to document param of a param function #2683

@KillyMXI

Description

@KillyMXI

Search terms

argument description, parameter description, parameter of an arrow function, lambda

Question

Previously (with version 0.23.x) I was using the following doc comment:

/**
 * ... irrelevant ...
 *
 * @param f - A function to produce a side effect...
 */
export function action (
  /**
   * @param data - Data object...
   * @param i - Position...
   */
  f: (data: Data, i: number) => void
): void;

Now (with 0.26.x) I noticed that data and i are left undescribed.
Looks like I have to change how I document them:

/**
 * ... irrelevant ...
 *
 * @param f - A function to produce a side effect...
 */
export function action (
  f: (
    /** Data object... */
    data: Data,
    /** Position... */
    i: number
  ) => void
): void;

Was this a conscious change or an omission?
I don't quite like how this looks in my code - harder to grasp.
So, I wonder whether it is the idiomatic way to document args of the arg function.


Support in VSCode:

  • @params show up when I hover over f in the implementation;
  • directly applied doc strings can show up in certain situations (not very practical) in the client code.

The second example might be preferential for the client code, but the support is not ideal, so I don't see significant advantage there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion about functionality

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions