How do I properly document the type of functions passed as arguments, without extracting them to another type?

This issue has been tracked since 2023-01-29.

Hi! To clarify the title, the following code:

/**
 *
 * Adds equality functions to a data object. This freezes an object.
 * HashCode is lazily evaluated and memoized.
 *
 * @param <D> The type of the data object
 * @param data The data object to add equality to
 * @param equals The equality function
 * @param hashCode The hash code function
 *
 * @returns The data object with equality added
 */
export default function <D extends Record<string, unknown>>(
  data: D,
  equals: (a: D, b: D) => boolean,
  hashCode: (data: D) => number
): D & HasEquals {
    // ....
}

Needs @param hashCode.__type and @param equals.__type, else validation will show the following:

./src/lib/utils/addEquality.ts:20:10 - warning addEquality.equals.__type does not have any documentation.
20      equals: (a: D, b: D) => boolean,

./src/lib/utils/addEquality.ts:21:12 - warning addEquality.hashCode.__type does not have any documentation.
21      hashCode: (data: D) => number

Gerrit0 wrote this answer on 2023-02-02

This looks like a bug in the validation, it should accept the comment on the parameter reflection as the comment.

More Details About Repo
Owner Name TypeStrong
Repo Name typedoc
Full Name TypeStrong/typedoc
Language TypeScript
Created Date 2014-05-24
Updated Date 2023-03-19
Star Count 6487
Watcher Count 68
Fork Count 639
Issue Count 48

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date