Typedoc: Currying support

Created on 19 Sep 2019  路  4Comments  路  Source: TypeStrong/typedoc

I just recently started using TypeDoc - mostly for documentation - but I am wondering if it just doesn't support currying or if I am implementing it incorrectly.

I have the below file:

/**
 * Helper File
 * @description Contains helper functions needed for multiple entities
 * @exports setParentData
 */

/** ignore this comment */
import React from "react";

/**
 * Takes in an array of props and runs the change function in props.
 * Used in the children where change is passed down from parent for state management.
 * Using currying to pass props, then field, then (e) change event for onchange in child.
 * @param {any} props
 * @param {string} field
 * @param {React.ChangeEvent} e
 */
export const setParentData = (props: any) => (field: string) => (
  e: React.ChangeEvent<any>
) => {
  props.change(field, e.currentTarget.value);
};

and get this output:
image

Thanks for any help in advance!

enhancement

Most helpful comment

The "Anonymous function" type certainly isn't ideal, we should support this pattern, and I thought we did... but apparently not. I don't think you did anything wrong.

All 4 comments

The "Anonymous function" type certainly isn't ideal, we should support this pattern, and I thought we did... but apparently not. I don't think you did anything wrong.

I just installed typedoc and experienced the same thing.

For example this function:

export const numberGreaterThan = (otherNum: number) => (num: number) => num > otherNum

got this signature:

numberGreaterThan(otherNum: number): (Anonymous function)

It's not just functions that returns functions though, it is higher order functions in general. Functions in parameters just becomes function
Example:

validateField<T>(...tuples: Array<[function, string]>): (Anonymous function)

This is still a thing today

In 0.20, the code in the OP renders as:

image

This still isn't exactly ideal, but the confusing non-indented tags is a theme issue, this issue has been resolved

Was this page helpful?
0 / 5 - 0 ratings