简体   繁体   中英

How to forward a TSDoc description within an object property

For example, I have a function:

/**
 * Function returns null
 */
const myFunction = () => {
  return null
}

And an object like this:

const internals = {
  myFunction: myFunction,
}

So I want to see this description: "Function returns null" at internals.myFunction in VScode.

But with notations like @inheritDoc, @link and such I just see them as is: {@inheritDoc myFunction}

I want to generate a solid d.ts with all necessary docs

Is it possible?

So I had a glance at React sources and there is the way:

Let assume the function is in a file my-function.ts :

/**
 * Function returns null
 */
export const myFunction = () => {
  return null
}

then I reexport all my functions like this:

functions.ts :

import {myFunction} from './my-function'
import {myFunction2} from './my-function2'
// and other imports

export {
  myFunction,
  myFunction2,
}

And finally:

internals.ts

import * as functions from './functions'

const internals = {
  functions,
}

So by this way I finally can see "Function returns null" at

internals.functions.myFunction

So check my codesandbox for the example

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