在下面的示例中,VS Code 1.77.3 和 TypeScript 5.0.4 似乎没有提取
@deprecated
标签,我不明白为什么?用例是将 lodash 模板函数标记为已弃用。
import _template from 'lodash/template';
export {
/** @deprecated Deprecated. Use JavaScript template string instead. */
_template as template
};
另请注意,在使用
_.template
函数时,VS 代码通过将 template
函数正确标记为已弃用,并在帮助弹出窗口中显示附加注释。
功能完成后好像忘记了它已经弃用了,不再显示划掉了
Dimiva 的回答 应该对你有用。
概括:
// exporter.js
export const thing = "hello world!";
// reexporter.js
export {
/** @deprecated blah blah reasons. */
thing
};
// importer.js
import { thing } from "reexporter.js"
详细说明原因:
See Override JSDoc for re-exported types / enum / classes / interfaces #42684,其中要求覆盖 JSDocs 以重新导出的一般功能,后来在 feat(42684) 中实现:为重新导出的类型/枚举/类/接口覆盖 JSDoc #47293。该 PR 合并到 TypeScript 的主要分支发生在 2022 年 1 月 25 日。虽然 issue ticket 和 PR 没有相关的里程碑,但这只是在 TypeScript 4.6 Beta 发布之前一点,所以如果这个功能在 TypeScript 4.6 或 4.7 中,我不会感到惊讶。
在撰写本文时,VS Code 的捆绑 TypeScript(它默认用于 IntelliSense)已经是 TypeScript 5.0 版本了。为了您的参考/学习目的,此信息是通过谷歌搜索“
github typescript issues mark reexport as deprecated
”找到的。
import _template from 'lodash/template';
export {
/** @deprecated Deprecated. Use JavaScript template string instead. */
_template as template
};