typedoc icon indicating copy to clipboard operation
typedoc copied to clipboard

Currying support

Open jfreitas-dev opened this issue 7 years ago • 4 comments

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!

jfreitas-dev avatar Sep 19 '19 19:09 jfreitas-dev

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.

Gerrit0 avatar Sep 21 '19 21:09 Gerrit0

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)

Herlevsen avatar Sep 30 '19 21:09 Herlevsen

This is still a thing today

cyrilchapon avatar Jun 10 '20 15:06 cyrilchapon

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

Gerrit0 avatar Dec 27 '20 00:12 Gerrit0