I would like to mark a property (for example, qux
below) as deprecated:
JavaScript
x
8
1
/**
2
@typedef {object} Foo
3
@property {string} bar
4
@property {symbol} qux - How to deprecate it?
5
@deprecated @property {symbol} qux2 - Doesn't work
6
@property {symbol} qux3 @deprecated - This marks the whole of Foo as deprecated
7
*/
8
I should mention, I’d like to do this in a JSDoc comment, not using TypeScript.
Advertisement
Answer
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).
For e.g.:
JavaScript
1
18
18
1
/**
2
* Explain the interface ...
3
*/
4
export interface test {
5
/**
6
* Foo property
7
*/
8
Foo: string;
9
/**
10
* @deprecated Use {@link test.qux2} instead.
11
*/
12
qux: string;
13
/**
14
* qux2 property
15
*/
16
qux2: string;
17
}
18
Results in:
In classes for e.g.:
JavaScript
1
29
29
1
/**
2
* Class description ...
3
*/
4
class User {
5
/**
6
* Holds user's name
7
*/
8
name = "";
9
/**
10
* Holds user's surname
11
*/
12
surname = "";
13
/**
14
* @deprecated Holds user height
15
*/
16
height = 0;
17
18
/**
19
* constructor
20
*/
21
22
constructor(name, surname) {
23
this.name = name;
24
this.surname = surname;
25
}
26
}
27
28
const me = new User("Arslan", "Sohail Bano");
29
Results: