[英]How to mark a property deprecated in a @typedef?
I would like to mark a property (for example, qux
below) as deprecated:我想将一个属性(例如下面的
qux
)标记为已弃用:
/**
@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 comment, not using TypeScript.我应该提一下,我想在 JSDoc 评论中这样做,而不是使用 TypeScript。
As far as i know the @deprecated tag can be only used for deprecating anything else than an entire symbol据我所知,@deprecated 标签只能用于弃用除整个符号以外的任何其他内容
Following the jsdoc docs this is the only way you can use @deprecated按照 jsdoc 文档,这是您可以使用 @deprecated 的唯一方法
/**
* @deprecated since version 2.0.0
*/
function old() {
}
https://jsdoc.app/tags-deprecated.html https://jsdoc.app/tags-deprecated.html
According 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).根据 tsdoc 上的Issue#131 ,您实际上可以在属性上使用
@deprecated
,您只需将它设置在 object 中(也适用于 JS)。
For eg:例如:
/**
* 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 eg:在例如类中:
/**
* 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:结果:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.