admin管理员组文章数量:1352819
I would like to mark a property (for example, qux
below) as deprecated:
/**
@typedef {object} Foo
@property {string} bar
@property {symbol} qux - How to deprecate it?
@deprecated @property {symbol} qux2 - Doesn't work
@property {symbol} qux3 @deprecated - This marks the whole of Foo as deprecated
*/
I should mention, I'd like to do this in a JSDoc ment, not using TypeScript.
I would like to mark a property (for example, qux
below) as deprecated:
/**
@typedef {object} Foo
@property {string} bar
@property {symbol} qux - How to deprecate it?
@deprecated @property {symbol} qux2 - Doesn't work
@property {symbol} qux3 @deprecated - This marks the whole of Foo as deprecated
*/
I should mention, I'd like to do this in a JSDoc ment, not using TypeScript.
Share Improve this question edited Jun 14, 2022 at 17:12 P Varga asked Jun 9, 2022 at 17:35 P VargaP Varga 20.3k13 gold badges77 silver badges118 bronze badges2 Answers
Reset to default 9 +100According to Issue#131 over at tsdoc, you can actually use @deprecated
on properties, you just have to set it inside the object (works with JS as well).
For e.g.:
/**
* Explain the interface ...
*/
export interface test {
/**
* Foo property
*/
Foo: string;
/**
* @deprecated Use {@link test.qux2} instead.
*/
qux: string;
/**
* qux2 property
*/
qux2: string;
}
Results in:
In classes for e.g.:
/**
* Class description ...
*/
class User {
/**
* Holds user's name
*/
name = "";
/**
* Holds user's surname
*/
surname = "";
/**
* @deprecated Holds user height
*/
height = 0;
/**
* constructor
*/
constructor(name, surname) {
this.name = name;
this.surname = surname;
}
}
const me = new User("Arslan", "Sohail Bano");
Results:
When using the deprecated property.
As far as i know the @deprecated tag can be only used for deprecating anything else than an entire symbol
Following the jsdoc docs this is the only way you can use @deprecated
/**
* @deprecated since version 2.0.0
*/
function old() {
}
https://jsdoc.app/tags-deprecated.html
本文标签: javascriptHow to mark a property deprecated in a typedefStack Overflow
版权声明:本文标题:javascript - How to mark a property deprecated in a @typedef? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743903328a2559070.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论