[在很多地方使用函数签名时,我经常将它们保存为单独的类型。
问题是,每当我在接口或复合类型中使用此类类型时,当悬停在属性上时,它不会自动向我显示基础类型的文档...
/**
* Documentation for function that is used in multiple places
*/
export type MyFunction = () => void
export interface SomeInferface {
/**
* I HAVE to duplicate the documentation manually here, if not, it won't show up in the interface...
*/
myFunction: MyFunction
}
export type SomeType = {
/**
* I HAVE to duplicate the documentation manually here, if not, it won't show up in the type...
*/
myFunction: MyFunction
}
这使使用我的库的开发人员对veeeery不友好。因此,为了缓解这种情况,我必须手动在每个接口和使用它的复合类型内复制该类型的文档块!
但是如果我更改它却忘记在某个地方更新它,这反过来很容易出错...
如何自动让VSCode在接口和复合类型中显示类型文档?
[在所有地方都搜寻了很长时间之后,看来这还不可能。这是一个开放功能要求:https://github.com/microsoft/TypeScript/issues/37876