forked from microsoft/rushstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDocClass1.ts
More file actions
385 lines (340 loc) · 8.11 KB
/
DocClass1.ts
File metadata and controls
385 lines (340 loc) · 8.11 KB
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
/**
* A class used to exposed events.
* @public
* {@docCategory SystemEvent}
*
* @myCustomTag
*/
export class SystemEvent {
/**
* Adds an handler for the event.
*/
public addHandler(handler: () => void): void {}
}
/**
* Example base class
* @public
* {@docCategory DocBaseClass}
*/
export class DocBaseClass {
/**
* The simple constructor for `DocBaseClass`
*/
public constructor();
/**
* The overloaded constructor for `DocBaseClass`
*/
public constructor(x: number);
public constructor(x?: number) {}
}
/**
* @public
* {@docCategory DocBaseClass}
*/
export interface IDocInterface1 {
/**
* Does something
*/
regularProperty: SystemEvent;
}
/**
* @public
* {@docCategory DocBaseClass}
*/
export interface IDocInterface2 extends IDocInterface1 {
/**
* @deprecated Use `otherThing()` instead.
*/
deprecatedExample(): void;
}
/**
* A namespace containing an ECMAScript symbol
* @public
*/
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace EcmaSymbols {
/**
* An ECMAScript symbol
*/
export const example: unique symbol = Symbol('EcmaSymbols.exampleSymbol');
}
/**
* Some less common TypeScript declaration kinds.
* @public
* {@docCategory DocClass1}
*/
export interface IDocInterface3 {
/**
* Call signature
* @param x - the parameter
*/
(x: number): number;
/**
* Construct signature
*/
new (): IDocInterface1;
/**
* Indexer
* @param x - the parameter
*/
[x: string]: string;
/**
* ECMAScript symbol
*/
[EcmaSymbols.example]: string;
/**
* A quoted identifier with redundant quotes.
*/
// prettier-ignore
"redundantQuotes": string;
/**
* An identifier that does need quotes. It misleadingly looks like an ECMAScript symbol.
*/
// prettier-ignore
"[not.a.symbol]": string;
}
/**
* Generic class.
* @public
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export class Generic<T> {}
/**
* Type union in an interface.
* @public
* {@docCategory DocClass1}
*/
export interface IDocInterface4 {
/**
* a union type
*/
stringOrNumber: string | number;
/**
* a union type with a function
*/
numberOrFunction: number | (() => number);
/**
* make sure html entities are escaped in tables.
*/
generic: Generic<number>;
/**
* Test newline rendering when code blocks are used in tables
*/
Context: ({ children }: { children: string }) => boolean;
}
/**
* Type parameter constraint used by test case below.
* @public
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
export interface Constraint {}
/**
* Type parameter default type used by test case below.
* @public
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
export interface DefaultType {}
/**
* This is an example class.
*
* @remarks
* {@link DocClass1.(exampleFunction:1)|Link to overload 1}
*
* {@link DocClass1.(exampleFunction:2)|Link to overload 2}
*
* @public
* {@docCategory DocClass1}
*/
export class DocClass1 extends DocBaseClass implements IDocInterface1, IDocInterface2 {
/**
* Some protected property.
*/
protected protectedProperty: string;
/**
* Some property with multiple modifiers.
*/
protected static readonly multipleModifiersProperty: boolean;
/**
* This event is fired whenever the object is modified.
* @eventProperty
*/
public readonly modifiedEvent: SystemEvent;
/**
* This event should have been marked as readonly.
* @eventProperty
*/
public malformedEvent: SystemEvent;
/**
* This is a regular property that happens to use the SystemEvent type.
*/
public regularProperty: SystemEvent;
/**
* An internal class constructor.
* @internal
*/
public constructor(name: string) {
super();
}
/**
* This is an overloaded function.
* @param a - the first string
* @param b - the second string
*
* @throws `Error`
* The first throws line
*
* @throws The second throws line
*/
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
exampleFunction(a: string, b: string): string;
/**
* This is also an overloaded function.
* @param x - the number
*
* @defaultValue 123
*/
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
exampleFunction(x: number): number;
public exampleFunction(x: number | string, y?: string): string | number {
return x;
}
/**
* This is a function with an optional parameter.
* @param x - the number
*/
public optionalParamFunction(x?: number): void {}
public get readonlyProperty(): string {
return 'hello';
}
public get writeableProperty(): string {
return 'hello';
}
public set writeableProperty(value: string) {}
/**
* API Extractor will surface an `ae-missing-getter` finding for this property.
*/
// eslint-disable-next-line accessor-pairs
public set writeonlyProperty(value: string) {}
/**
* An example with tables:
* @remarks
* <table>
* <tr>
* <td>John</td>
* <td>Doe</td>
* </tr>
* </table>
*/
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
tableExample(): void {}
/**
* Example: "\{ \\"maxItemsToShow\\": 123 \}"
*
* The regular expression used to validate the constraints is /^[a-zA-Z0-9\\-_]+$/
*/
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
interestingEdgeCases(): void {}
/**
* @deprecated Use `otherThing()` instead.
*/
public deprecatedExample(): void {}
/**
* Returns the sum of two numbers.
*
* @remarks
* This illustrates usage of the `@example` block tag.
*
* @param x - the first number to add
* @param y - the second number to add
* @returns the sum of the two numbers
*
* @example
* Here's a simple example:
* ```
* // Prints "2":
* console.log(DocClass1.sumWithExample(1,1));
* ```
* @example
* Here's an example with negative numbers:
* ```
* // Prints "0":
* console.log(DocClass1.sumWithExample(1,-1));
* ```
*/
public static sumWithExample(x: number, y: number): number {
return x + y;
}
/**
* This is a method with a complex type parameter.
* @param x - some generic parameter.
*/
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
public genericWithConstraintAndDefault<T extends Constraint = DefaultType>(x: T) {}
}
/**
* Interface without inline tag to test custom TOC
* @public
*/
export interface IDocInterface5 {
/**
* Property of type string that does something
*
* @defaultValue "Hello World"
*/
regularProperty: string;
}
/**
* Interface without inline tag to test custom TOC with injection
* @public
*/
export interface IDocInterface6 {
/**
* Property of type number that does something
*/
regularProperty: number;
}
/**
* Interface for testing complex properties
* @public
*/
export interface IDocInterface6 {
arrayProperty: IDocInterface1[];
tupleProperty: [IDocInterface1, IDocInterface2];
unionProperty: IDocInterface1 | IDocInterface2;
intersectionProperty: IDocInterface1 & IDocInterface2;
typeReferenceProperty: Generic<IDocInterface1>;
genericReferenceMethod<T>(x: T): T;
}
/**
* Interface for testing optional properties
* @public
*/
export interface IDocInterface7 {
/** Description of optionalField */
optionalField?: boolean;
// Missing description
optionalUndocumentedField?: boolean;
/** Description of optionalReadonlyField */
readonly optionalReadonlyField?: boolean;
/** Description of optionalMember */
optionalMember?();
}
/**
* Class that merges with interface
*
* @remarks
* {@link (DocClassInterfaceMerge:class)|Link to class}
*
* {@link (DocClassInterfaceMerge:interface)|Link to interface}
*
* @public
*/
export class DocClassInterfaceMerge {}
/**
* Interface that merges with class
* @public
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
export interface DocClassInterfaceMerge {}