futurGH / ts-to-jsdoc

Transpile TypeScript code to fully compatible JavaScript + JSDoc comments.
MIT License
179 stars 17 forks source link

param is too verbose. should use only simple param names #5

Closed milahu closed 2 years ago

milahu commented 2 years ago

input

function f({
  a,
  b,
}: {
  a: string,
  b: number,
}, arg2: string) {
  return a + arg2
}

actual

/**
 * @param {{
 *   a: string,
 *   b: number,
 * }} {
 *   a,
 *   b,
 * }
 * @param {string} arg2
 * @returns {string}
 */
function f({ a, b, }, arg2) {
    return a + arg2;
}

expected: remove the { a, b }

/**
 * @param {{
 *   a: string,
 *   b: number,
 * }}
 * @param {string} arg2
 * @returns {string}
 */
function f({ a, b, }, arg2) {
    return a + arg2;
}

javascript has only positional arguments (compared to python's kwargs) so it's safe to skip the variable name if its too complex