TypeStrong / typedoc

Documentation generator for TypeScript projects.
https://typedoc.org
Apache License 2.0
7.74k stars 700 forks source link

Function exported as variable despite @function tag #858

Closed jerylvaz closed 3 years ago

jerylvaz commented 6 years ago

v2.7.2

/**
 * Promisified version of fs.writeFile().
 * @function writeFileAsync
 */
export const writeFileAsync: Function = util.promisify(fs.writeFile);

typedoc

CLI options: --readme ./README.md --mode file --includeDeclarations --excludePrivate --excludeExternals

aciccarello commented 6 years ago

Hello @jerylvaz, in general, TypeDoc does not override type information from jsdoc tags. The @function tag is not officially supported. Since the variable is defined as a const TypeScript considers it a variable with a function signature. I wonder if it would make sense to tag callable variables as functions.

justinfagnani commented 5 years ago

I wonder if it would make sense to tag callable variables as functions.

This is definitely what I'd want.

Ixonal commented 5 years ago

I'm running into this too. The documentation generated shows the whole function implementation when I set up memoization...

/**
 * Determines whether or not the given string can be considered a url
 */
export const isUrl = memoize(
  function isUrl(str: string): boolean {
    urlParser.href = str;
    return !!(urlParser.host && urlParser.host !== window.location.host);
  }
);

It may be of benefit to officially support the @function annotation for this specific situation...

Gerrit0 commented 3 years ago

In 0.20, TypeDoc renders the OP's code block as the following:

image

Removing the (bad) type annotation : Function, results in rendering this:

image