-
Notifications
You must be signed in to change notification settings - Fork 109
/
Copy pathjsdoc.ts
160 lines (130 loc) · 3 KB
/
jsdoc.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/**
* @fileoverview
* @suppress {uselessCode}
*/
/**
* @param foo a string.
* @return return comment.
*/
function jsDocTestFunction(foo: string, baz: string): string {
return foo;
}
/**
* @returns return comment in a "@returns" block.
*/
function returnsTest(): string {
return 'abc';
}
/**
* @param {badTypeHere} foo no types allowed.
*/
function jsDocTestBadDoc(foo: string) {}
/**
* Test JS doc on class.
* @madeUpTag This tag will be escaped, because Closure disallows it.
* @param What does this even mean?
*/
class JSDocTest {
/** @internal */
static X: string[] = [];
/** @internal */
x: string[] = [];
/** @export */
exported: string;
/** @export {number} */
badExport: string;
stringWithoutJSDoc: string;
/** @type {badType} */
typedThing: number;
/** @enum {string} */
badEnumThing = {A: 'a'};
/** @const {string} */
badConstThing = 'a';
/** @typedef {string} */
badTypeDef: string;
}
/** @param What does this even mean? */
interface MyInterface {}
/** @template T */
class BadTemplated {}
/** @dict */
class BadDict {}
/** @lends {BadDict} */
class BadLends {}
/**
* @throws {Error} JSCompiler treats this as pure documentation, no need to ban
* it.
*/
function fnThrows() {}
/** @this {string} */
function badThis() {}
/** @interface @record */
function BadInterface() {}
/**
* @madeUptag This tag will be escaped, because Closure disallows it.
* @see This tag will be kept, because Closure allows it.
*/
function x() {};
/**
* This class has JSDoc, but some of it should be stripped.
* @extends {IgnoreMe}
* @implements {IgnoreMeToo}
* @see Nothing.
*/
class RedundantJSDocShouldBeStripped {
/** @constructor */
constructor() {}
}
/**
* This comment has code that needs to be escaped to pass Closure checking.
* @example
*
* @Reflect
* function example() {}
* @Reflect.metadata(foo, bar)
* function example2() {}
*/
function JSDocWithBadTag() {}
/**
* For example,
* @madeUpTag
*/
const c = 'c';
/**
* Don't emit type comments for Polymer behaviors,
* as this breaks their closure plugin :-(
*
* @polymerBehavior
*/
const somePolymerBehavior = {};
/**
* Don't emit type comments for Polymer behaviors
* if they are declared via the Polymer function.
*/
let Polymer: any;
Polymer({behaviors: ['test' as any]});
/**
* This class has a 'template' tag, which we want to allow (because this is
* how to doc this) but not let Closure interpret (because we emit our own).
* The desired behavior is that the user-written @template comment (which
* talks about T) is dropped, but the tsickle-generated @template comment
* (which talks about T2) is preserved.
*
* @template T User-written comments on the template (typo of 'T1').
* @template T2 Another user comment.
*/
class Foo<T1, T2> {}
/**
* @define {boolean}
*/
const DEFINE_WITH_JSDOC_TYPE = 42;
/**
* @define
*/
const DEFINE_WITH_INFERRED_TYPE = false;
/**
* @define
*/
const DEFINE_WITH_DECLARED_TYPE: string = 'y';
/** @logTypeInCompiler */
const logTypeInCompiler = 0;