Skip to content

JSDoc @param does not work for function variables #36633

Open

Description

@AnyhowStep

TypeScript Version: 3.5.1, 3.7.5

Search Terms: jsdoc, param, variable, function

Code

function makeFoo() {
    return (x : number) => {}
}

/**
 * @param x - Comment
 */
const foo = makeFoo();
foo(/* No comment in hover */);

/**
 * @param x - Comment
 */
function foo2(x: number) {
    
}
foo2(/* Comment in hover */)

Expected behavior:
image

Actual behavior:
image

Playground Link: Playground

Related Issues: Couldn't find any


For my use case, I use factories to make functions a lot.

export const lPad = makeOperator3<string, bigint, string, string>(/*args*/);
export const rPad = makeOperator3<string, bigint, string, string>(/*args*/);
export const lTrim = makeOperator1<string, string>(/*args*/);
export const rTrim = makeOperator1<string, string>(/*args*/);

And I'd like to add JSDoc to these variables, because the parameter names aren't very descriptive, by themselves (left, mid, right, arg, etc.). But it seems like the JSDoc for @param does not show up in hover on VS Code and the Playground.

Activity

  1. AnyhowStep commented on Feb 5, 2020

    @AnyhowStep
    ContributorAuthor

    Clarification:
    There's hover for foo/foo2. Those come up fine.

    There's also hover for each parameter. They come up as you fill up the argument list of the function call. The parameter hover is missing the JSDoc.

  2. thanpolas commented on Mar 5, 2020

    @thanpolas

    I need this too, we use a specific pattern for exporting module where everything is defined under an object that's exported and the JSDoc autocompletes don't work:

    const model = (module.exporst = {});
    
    /** JSDoc tags will not autocomplete here */
    model.method = (param1, param2) => {};

    A small screencast of the issue: https://d.pr/i/IPpCGR

    screencast

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Needs InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions