简体   繁体   English

如何在 object 属性中转发 TSDoc 描述

[英]How to forward a TSDoc description within an object property

For example, I have a function:例如,我有一个 function:

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

And an object like this:还有一个像这样的 object:

const internals = {
  myFunction: myFunction,
}

So I want to see this description: "Function returns null" at internals.myFunction in VScode.所以我想在 VScode 的internals.myFunction中看到这个描述:“函数返回 null”。

But with notations like @inheritDoc, @link and such I just see them as is: {@inheritDoc myFunction}但是对于像@inheritDoc、@link 之类的符号,我只是按原样看待它们: {@inheritDoc myFunction}

I want to generate a solid d.ts with all necessary docs我想用所有必要的文档生成一个可靠的d.ts

Is it possible?可能吗?

So I had a glance at React sources and there is the way:所以我看了一下 React 的源代码,有办法:

Let assume the function is in a file my-function.ts :假设 function 在文件my-function.ts中:

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

then I reexport all my functions like this:然后我重新导出我的所有函数,如下所示:

functions.ts : 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 因此,请检查我的代码框以获取示例

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何订阅rxjs中另一个对象内引用的对象的属性更改 - How to subscribe to the property change of an object referenced within another object in rxjs 如何从 tsdoc / typedoc 中正确排除测试文件 - How to properly exclude test files from tsdoc / typedoc 如何将嵌套参数添加到 tsdoc 文档 - How do you add nested params to tsdoc documentation 如何显示嵌套在数组中的对象的匹配描述? - How to display matching description of an object nested in an array? 不可变 JS:在对象内的数组内设置对象中的属性 - Immutable JS: Set property in object within array within object 将 object 属性值传递给 Typescript Angular 中 object 中的另一个属性 - Pass object property value to another property within that object in Typescript Angular 在使用扩展运算符修改 object 属性时,如何保留数组中 object 的索引? - How can the index of an object within an array be preserved when modifying an object property while using the spread operator? 如何为jasmine编写自定义匹配器以查找对象属性是否位于一系列对象属性值中? - How to write a custom matcher for jasmine to find if the object properties lie within a range of object property values? 如何为具有扩展接口的泛型类型的函数参数做 TypeScript tsdoc 文档? - How to do TypeScript tsdoc documentation for function argument with generic type that extends an interface? 打字稿:属性的类型依赖于同一对象中的另一个属性 - Typescript: Type of a property dependent on another property within the same object
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM