简体   繁体   中英

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

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`.

This does works

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM