How to describe object properties parameters for a function in typescript TSDoc?

788 Views Asked by At

How do I add descriptions for a and b in TSDoc? I want the description be shown when I hover on a property argument in a function call like fn({ a }).

// This does not work

/**
 * @param props
 * @param props.a docs for a
 * @param props.b docs for b
 */
function fn({a, b}: {a: string, b: string}) {}


fn({ a })
//   ~
// Expecting hover info for `a`.
1

There are 1 best solutions below

0
Zotille On

This does works

interface Params {
  /** Desc for a */
  a?:string;
  b?:string;
}

/**
 * Desc for fn
 */
function fn({a, b}: Params) {}