question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JSDoc support for destructured parameters

See original GitHub issue

TypeScript Version: 2.0.3

Code

interface Foo {
    /**
     * A bar value
     */
    bar?: string;
}

/**
 * A function
 *
 * @param foo A param
 * @param { bar } Another param
 * @param bar Another param
 */
function foo(foo: string, { bar }: Foo): void {
    bar;
    foo;
}

foo('bar', { bar: 'play' });

Expected behavior:

Intellisense for the second argument, or the second argument properties.

Actual behavior:

No way of providing a description for the destructured elements of a destructured parameter.

destructured

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:35
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
eduardobcastrocommented, Apr 4, 2018

This does not work on version 1.21.1

/** Class representing a user. */
module.exports = class User {
  /**
  * Create a User.
  * @param {object} user
  * @param {string} user.id - The user id in uuid format
  * @param {string} user.name - The user name
  * @param {string} user.email - The user email
  * @param {string} user.password - The user password
  */
  constructor({id, name, email, password}) {
    this.id = id
    this.name = name
    this.email = email
    this.password = password
  }
}
3reactions
hellos3bcommented, May 1, 2020

Also an issue when functions return an interface

interface Returns {
  /** This object contains a getter that returns itself */
  get: (key: string) => string;
}

const buildObject = (): Returns => ({
  get: key => key
})

// shows jsdoc description when hovering over "obj1.get"
const obj1 = buildObject();
const a = obj1.get("key")

// Only shows signature "const get: (key: string) => string"
const {get} = buildObject();
const b = get("key");
Read more comments on GitHub >

github_iconTop Results From Across the Web

Document destructured function parameter in JSDoc
In WebStorm I have found that if I just describe the (after-destructuring) parameters and ignore the destructuring it mostly works except for ...
Read more >
Use JSDoc: @param
Documenting a destructuring parameter /** * Assign the project to an employee. * @param {Object} employee - The employee who is responsible for...
Read more >
JSDoc for destructured parameters generated incorrectly, like ...
For destructured parameters, WebStorm generates JSDoc that looks exactly like that for positional parameters: /** <-- press Ctrl+Enter here function foo({ a ...
Read more >
Joshua's Docs - JSDoc Cheatsheet and Type Safety Tricks
Type Guards; Annotating destructured parameters ... Repo: Types in JS, GitHub repo for discussing or getting help with JSDoc ...
Read more >
Destructured function parameters and code maintainability
... and how destructured function parameters could help us. ... We are documenting our functions with JSDoc, which will also help us see ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found