Skip to content

Contextually typed object method parameter doesn't have JSDoc attachedΒ #48303

@Josh-Cena

Description

@Josh-Cena

Bug Report

πŸ”Ž Search Terms

  • JSDoc object method parameter

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type Options = {
  /**
   * A callback to create a redirect rule.
   * @param path An existing route path
   * @returns All the paths from which we should redirect to `path`
   */
  createRedirects: (
    /** An existing route path */
    path: string,
  ) => string[] | string | null | undefined;
}

const options: Options = {
  createRedirects(path) {
    return null;
  }
}

πŸ™ Actual behavior

No JSDoc is shown when hovering over the path parameter:

image

πŸ™‚ Expected behavior

The JSDoc should be attached, either by recognizing the @param, or the comment directly attached to the parameter type.

The following all work:

Intellisense when completing the method

image

Intellisense when calling the method

image

Destructuring object parameter

type Options = {
  /**
   * A callback to create a redirect rule.
   * @returns All the paths from which we should redirect to `path`
   */
  createRedirects: (args: {
    /** An existing route path */
    path: string,
  }) => string[] | string | null | undefined;
}

const options: Options = {
  createRedirects({path}) {
    return null;
  }
}

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions