ts2jsdoc icon indicating copy to clipboard operation
ts2jsdoc copied to clipboard

Undefined for object destructuring

Open ozum opened this issue 7 years ago • 0 comments

Hi,

Function parameters with object destructuring generates undefined as name. Please see example simplified below. I edited it on the fly while simplifying, it may have some syntax errors:

/**
 * Connection configuration interface.
 */
export interface ConnectionConfig {
  /** Database name */
  database?: string;
  /** User name for connecting database */
  user?: string;
  /** Password for user */
  password?: string;
}

/**
 * Some description
 * @param [config] - Connection object to fill.
 * @return - Fully filled connection object.
 */
export function getConnectionObject({
  database,
  user = "user",
  password = "password",
}: ConnectionConfig = {}): ConnectionConfig {
  return {
    database,
    user,
    password,
  }
}

generates

/**
 * Some description
 * @param {module:pg-test-util/lib/types/connection-config.ConnectionConfig} undefined
 * @returns {module:pg-test-util/lib/types/connection-config.ConnectionConfig}
 */
export function getConnectionObject() {}

expected either

/**
 * Some description
 * @param {module:pg-test-util/lib/types/connection-config.ConnectionConfig} config
 * @returns {module:pg-test-util/lib/types/connection-config.ConnectionConfig}
 */
export function getConnectionObject() {}

or much better as typedoc gets interface details from interface definition:

/**
 * Some description
 * @param {module:pg-test-util/lib/types/connection-config.ConnectionConfig} config
 * @param {string}  [config.database] - Database name
 * @param {string}  [config.user=user] - User name for connecting database
 * @param {string}  [config.password=password] - Password for user
 * @returns {module:pg-test-util/lib/types/connection-config.ConnectionConfig}
 */
export function getConnectionObject() {}

ozum avatar Feb 20 '18 05:02 ozum