@arcgis/api-extractor 5.0.0-next.7 → 5.0.0-next.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/apiJson.d.ts CHANGED
@@ -4,8 +4,11 @@
4
4
  * `api.json` is a superset of custom-elements-manifest.
5
5
  *
6
6
  * @see https://custom-elements-manifest.open-wc.org/analyzer/getting-started/
7
+ * @privateRemarks
8
+ * PERF: when most code is moved from jsapi-extractor into api-extractor, replace
9
+ * ? with |undefined here to ensure more consistent shape.
7
10
  */
8
- export type ApiJson = {
11
+ export interface ApiJson {
9
12
  /**
10
13
  * The timestamp at which the metadata was generated, in the format
11
14
  * `YYYY-MM-DDThh:mm:ss`.
@@ -20,26 +23,7 @@ export type ApiJson = {
20
23
  * @remarks
21
24
  * Not present in vanilla custom-elements-manifest.
22
25
  */
23
- compiler: {
24
- /**
25
- * The name of the compiler that generated the metadata.
26
- *
27
- * @example "@arcgis/api-extractor"
28
- */
29
- name: string;
30
- /**
31
- * The version of the compiler that generated the metadata.
32
- *
33
- * @example "4.32.0"
34
- */
35
- version: string;
36
- /**
37
- * The version of TypeScript that was used to generate the metadata.
38
- *
39
- * @example "5.4.5"
40
- */
41
- typescriptVersion: string;
42
- };
26
+ compiler: ApiJsonCompiler;
43
27
  /**
44
28
  * The version of the schema used in this file.
45
29
  *
@@ -53,7 +37,7 @@ export type ApiJson = {
53
37
  * contains information irrelevant to custom element catalogs and
54
38
  * documentation viewers.
55
39
  *
56
- * @remarks
40
+ * @deprecated
57
41
  * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
58
42
  * with custom-elements-manifest.
59
43
  */
@@ -71,33 +55,51 @@ export type ApiJson = {
71
55
  *
72
56
  * @default false
73
57
  *
74
- * @remarks
58
+ * @deprecated
75
59
  * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
76
60
  * with custom-elements-manifest.
77
61
  */
78
- deprecated?: boolean | string;
79
- };
62
+ deprecated?: string | true;
63
+ }
64
+ export interface ApiJsonCompiler {
65
+ /**
66
+ * The name of the compiler that generated the metadata.
67
+ *
68
+ * @example "@arcgis/api-extractor"
69
+ */
70
+ name: string;
71
+ /**
72
+ * The version of the compiler that generated the metadata.
73
+ *
74
+ * @example "4.32.0"
75
+ */
76
+ version: string;
77
+ /**
78
+ * The version of TypeScript that was used to generate the metadata.
79
+ *
80
+ * @example "5.4.5"
81
+ */
82
+ typescriptVersion: string;
83
+ }
80
84
  export type ApiModule = ApiJavaScriptModule;
81
- export type ApiJavaScriptModule = {
85
+ export interface ApiJavaScriptModule extends ApiWithDescription, ApiWithDocsTags, ApiWithUnusedSummary {
82
86
  kind: "javascript-module";
83
87
  /**
84
- * Path to the javascript file needed to be imported.
88
+ * Public import path for the module
85
89
  *
86
- * @example "src/components/property-types/property-types.tsx"
90
+ * @example "components/arcgis-map"
87
91
  */
88
92
  path: string;
89
93
  /**
90
- * A markdown summary suitable for display in a listing.
94
+ * The original source file path, relative to extraction root (most commonly
95
+ * src/ folder).
96
+ *
97
+ * @example "components/map/map.tsx"
91
98
  *
92
99
  * @remarks
93
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
94
- * with custom-elements-manifest.
95
- */
96
- summary?: string;
97
- /**
98
- * A markdown description of the module.
100
+ * Not present in vanilla custom-elements-manifest.
99
101
  */
100
- description?: string;
102
+ sourcePath: string;
101
103
  /**
102
104
  * The declarations of a module.
103
105
  *
@@ -115,17 +117,67 @@ export type ApiJavaScriptModule = {
115
117
  * Whether the module is deprecated.
116
118
  * If the value is a string, it's the reason for the deprecation.
117
119
  *
120
+ * @remarks
121
+ * If module is marked as deprecated, all its declarations should also be
122
+ * marked as deprecated. This is because in TypeScript, a usage of a
123
+ * declaration will only be marked as deprecated if the declaration itself
124
+ * is marked as deprecated, rather than its module.
125
+ *
118
126
  * @default false
119
127
  */
120
- deprecated?: boolean | string;
121
- };
122
- export type ApiExport = ApiCustomElementExport | ApiJavaScriptExport;
128
+ deprecated?: string | true;
129
+ }
130
+ export interface ApiWithDescription {
131
+ /**
132
+ * A markdown description of an api node
133
+ */
134
+ description?: string;
135
+ }
136
+ export interface ApiWithDocsTags {
137
+ docsTags?: ApiDocsTag[];
138
+ }
139
+ export interface ApiWithDeprecated {
140
+ /**
141
+ * Whether the node is deprecated.
142
+ * If the value is a string, it's the reason for the deprecation.
143
+ *
144
+ * @default false
145
+ */
146
+ deprecated?: string | true;
147
+ }
148
+ export interface ApiWithUnusedSummary {
149
+ /**
150
+ * A markdown summary suitable for display in a listing.
151
+ *
152
+ * @deprecated
153
+ * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
154
+ * with custom-elements-manifest.
155
+ */
156
+ summary?: string;
157
+ }
123
158
  /**
159
+ * A descriptor for a single JSDoc tag found in a block comment.
160
+ *
124
161
  * @remarks
125
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
126
- * with custom-elements-manifest.
162
+ * Some tags have dedicated fields. Those will be excluded from array of
163
+ * "docsTags".
127
164
  */
128
- export type ApiJavaScriptExport = {
165
+ export interface ApiDocsTag {
166
+ /**
167
+ * The tag name (immediately following the '@').
168
+ *
169
+ * @example "since"
170
+ */
171
+ name: string;
172
+ /**
173
+ * The description that immediately follows the tag name.
174
+ *
175
+ * @example "4.31"
176
+ */
177
+ text?: string;
178
+ }
179
+ export type ApiExport = ApiCustomElementExport | ApiJavaScriptExport | ApiTypeScriptExport;
180
+ export interface ApiJavaScriptExport {
129
181
  kind: "js";
130
182
  /**
131
183
  * The name of the exported symbol.
@@ -151,9 +203,23 @@ export type ApiJavaScriptExport = {
151
203
  * If the value is a string, it's the reason for the deprecation.
152
204
  *
153
205
  * @default false
206
+ * @deprecated
207
+ * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
208
+ * with custom-elements-manifest. Read the deprecated status from the declaration.
154
209
  */
155
- deprecated?: boolean | string;
156
- };
210
+ deprecated?: string | true;
211
+ }
212
+ /**
213
+ * Indicates that the export is type-only and has no runtime impact (is a type alias
214
+ * or an interface).
215
+ *
216
+ * @remarks
217
+ * Not present in vanilla custom-elements-manifest, but may be added in the future.
218
+ * See https://github.com/webcomponents/custom-elements-manifest/pull/77#issuecomment-873552677
219
+ */
220
+ export interface ApiTypeScriptExport extends Omit<ApiJavaScriptExport, "kind"> {
221
+ kind: "ts";
222
+ }
157
223
  /**
158
224
  * A global custom element definition, ie the result of a
159
225
  * `customElements.define()` call.
@@ -161,7 +227,7 @@ export type ApiJavaScriptExport = {
161
227
  * This is represented as an export because a definition makes the element
162
228
  * available outside of the module it's defined it.
163
229
  */
164
- export type ApiCustomElementExport = {
230
+ export interface ApiCustomElementExport {
165
231
  kind: "custom-element-definition";
166
232
  /**
167
233
  * The tag name of the custom element.
@@ -180,13 +246,13 @@ export type ApiCustomElementExport = {
180
246
  * If the value is a string, it's the reason for the deprecation.
181
247
  *
182
248
  * @default false
183
- * @remarks
249
+ * @deprecated
184
250
  * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
185
- * with custom-elements-manifest.
251
+ * with custom-elements-manifest. Read the deprecated status from the declaration.
186
252
  */
187
- deprecated?: boolean | string;
188
- };
189
- export type ApiDeclaration = ApiClassDeclaration | ApiCustomElementDeclaration | ApiCustomElementMixinDeclaration | ApiFunctionDeclaration | ApiMixinDeclaration | ApiVariableDeclaration;
253
+ deprecated?: string | true;
254
+ }
255
+ export type ApiDeclaration = ApiClassDeclaration | ApiCustomElementDeclaration | ApiCustomElementMixinDeclaration | ApiFunctionDeclaration | ApiInterfaceDeclaration | ApiMixinDeclaration | ApiVariableDeclaration;
190
256
  /**
191
257
  * A reference to an export of a module.
192
258
  *
@@ -200,7 +266,7 @@ export type ApiDeclaration = ApiClassDeclaration | ApiCustomElementDeclaration |
200
266
  * References to global symbols like `Array`, `HTMLElement`, or `Event` should
201
267
  * use a `package` name of `"global:"`.
202
268
  */
203
- export type ApiReference = {
269
+ export interface ApiReference {
204
270
  /**
205
271
  * @example "AreaMeasurementAnalysis"
206
272
  */
@@ -219,23 +285,15 @@ export type ApiReference = {
219
285
  * @example "https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html"
220
286
  */
221
287
  viewUrl?: string;
222
- };
288
+ }
223
289
  /**
224
- * A reference to the source of a declaration or member.
225
- *
226
290
  * @remarks
227
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
228
- * with custom-elements-manifest.
291
+ * Not present in vanilla custom-elements-manifest.
229
292
  */
230
- export type ApiSourceReference = {
231
- /**
232
- * An absolute URL to the source (ie. a GitHub URL).
233
- */
234
- href: string;
235
- };
293
+ export interface ApiReferenceWithTypeArguments extends ApiReference {
294
+ typeArguments?: ApiType[];
295
+ }
236
296
  /**
237
- * A description of a custom element class.
238
- *
239
297
  * Custom elements are JavaScript classes, so this extends from
240
298
  * `ClassDeclaration` and adds custom-element-specific features like attributes,
241
299
  * events, and slots.
@@ -252,7 +310,7 @@ export type ApiSourceReference = {
252
310
  * these cases one `Module` should contain the `CustomElement` without a
253
311
  * tagName, and another `Module` should contain the `CustomElementExport`.
254
312
  */
255
- export type ApiCustomElementDeclaration = Omit<ApiClassDeclaration, "members"> & {
313
+ export interface ApiCustomElementDeclaration extends ApiClassDeclaration, ApiWithPrivacy {
256
314
  /**
257
315
  * An optional tag name that should be specified if this is a
258
316
  * self-registering element.
@@ -274,7 +332,6 @@ export type ApiCustomElementDeclaration = Omit<ApiClassDeclaration, "members"> &
274
332
  */
275
333
  pascalCaseName: string;
276
334
  members: ApiCustomElementMember[];
277
- superclass: ApiReference;
278
335
  /**
279
336
  * The attributes that this element is known to understand.
280
337
  *
@@ -283,10 +340,6 @@ export type ApiCustomElementDeclaration = Omit<ApiClassDeclaration, "members"> &
283
340
  * "attributes" is not necessary.
284
341
  */
285
342
  attributes?: ApiAttribute[];
286
- /**
287
- * The events that this element fires.
288
- */
289
- events?: ApiEvent[];
290
343
  /**
291
344
  * The shadow dom content slots that this element accepts.
292
345
  */
@@ -300,71 +353,47 @@ export type ApiCustomElementDeclaration = Omit<ApiClassDeclaration, "members"> &
300
353
  */
301
354
  customElement: true;
302
355
  /**
356
+ * @default "shadow"
357
+ *
303
358
  * @remarks
304
359
  * Not present in vanilla custom-elements-manifest.
305
360
  */
306
- docsTags?: ApiDocsTag[];
361
+ encapsulation?: "none" | "shadow";
307
362
  /**
308
363
  * The path from which the component can be imported.
309
364
  *
365
+ * @deprecated Use ApiModule.path instead.
366
+ *
310
367
  * @example "components/arcgis-area-measurement-2d"
311
368
  *
312
369
  * @remarks
313
370
  * Not present in vanilla custom-elements-manifest.
314
371
  */
315
372
  importPath: string;
373
+ }
374
+ export interface ApiWithPrivacy {
316
375
  /**
317
- * @default "shadow"
318
- *
319
- * @remarks
320
- * Not present in vanilla custom-elements-manifest.
321
- */
322
- encapsulation?: "none" | "shadow";
323
- };
324
- /**
325
- * A descriptor for a single JSDoc tag found in a block comment.
326
- *
327
- * @remarks
328
- * Some tags have dedicated fields. Those will be excluded from array of
329
- * "docsTags".
330
- */
331
- export type ApiDocsTag = {
332
- /**
333
- * The tag name (immediately following the '@').
376
+ * @default "public"
334
377
  *
335
- * @example "since"
336
- */
337
- name: string;
338
- /**
339
- * The description that immediately follows the tag name.
378
+ * If this field is absent, default value is assumed.
379
+ * All private fields are excluded from the api.json.
380
+ * So in practice, this value will be either "protected" or undefined.
340
381
  *
341
- * @example "4.31"
382
+ * \@arcgis/api-extractor may only ever set this field on class members, even
383
+ * though the original spec also allows it on classes and events.
342
384
  */
343
- text?: string;
344
- };
385
+ privacy?: "private" | "protected" | "public";
386
+ }
345
387
  /**
346
- * For most use cases, the "members" array includes properties will all the
388
+ * For most use cases, the "members" array includes properties with all the
347
389
  * information included in the "attributes" array. Thus directly accessing
348
390
  * "attributes" is not necessary.
349
391
  */
350
- export type ApiAttribute = {
392
+ export interface ApiAttribute extends ApiWithDeprecated, ApiWithDescription, ApiWithInheritance, ApiWithUnusedSummary {
351
393
  /**
352
394
  * @example "initial-count"
353
395
  */
354
396
  name: string;
355
- /**
356
- * A markdown summary suitable for display in a listing.
357
- *
358
- * @remarks
359
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
360
- * with custom-elements-manifest.
361
- */
362
- summary?: string;
363
- /**
364
- * A markdown description.
365
- */
366
- description?: string;
367
- inheritedFrom?: ApiReference;
368
397
  /**
369
398
  * The type that the attribute will be serialized/deserialized as.
370
399
  */
@@ -384,151 +413,95 @@ export type ApiAttribute = {
384
413
  * @example "initialCount"
385
414
  */
386
415
  fieldName?: string;
387
- /**
388
- * Whether the attribute is deprecated.
389
- * If the value is a string, it's the reason for the deprecation.
390
- *
391
- * @default false
392
- */
393
- deprecated?: boolean | string;
394
- };
395
- export type ApiEvent = {
416
+ }
417
+ export interface ApiEvent extends ApiWithDescription, ApiWithDocsTags, ApiWithDeprecated, ApiWithInheritance, ApiWithPrivacy, ApiWithUnusedSummary {
396
418
  /**
397
419
  * @example "arcgisClick"
398
420
  */
399
421
  name: string;
400
- /**
401
- * A markdown summary suitable for display in a listing.
402
- *
403
- * @remarks
404
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
405
- * with custom-elements-manifest.
406
- */
407
- summary?: string;
408
- /**
409
- * A markdown description.
410
- */
411
- description?: string;
412
422
  /**
413
423
  * The type of the event object that's fired.
414
424
  */
415
425
  type: ApiType;
416
- inheritedFrom?: ApiReference;
417
- /**
418
- * Whether the event is deprecated.
419
- * If the value is a string, it's the reason for the deprecation.
420
- *
421
- * @default false
422
- */
423
- deprecated?: boolean | string;
424
- /**
425
- * @remarks
426
- * Not present in vanilla custom-elements-manifest.
427
- */
428
- docsTags?: ApiDocsTag[];
429
426
  /**
430
427
  * @default true
431
428
  *
432
429
  * @remarks
433
430
  * Not present in vanilla custom-elements-manifest.
434
431
  */
435
- bubbles?: boolean;
432
+ bubbles?: false;
436
433
  /**
437
434
  * @default true
438
435
  *
439
436
  * @remarks
440
437
  * Not present in vanilla custom-elements-manifest.
441
438
  */
442
- cancelable?: boolean;
439
+ cancelable?: false;
443
440
  /**
444
441
  * @default true
445
442
  *
446
443
  * @remarks
447
444
  * Not present in vanilla custom-elements-manifest.
448
445
  */
449
- composed?: boolean;
446
+ composed?: false;
447
+ }
448
+ export interface ApiWithInheritance {
450
449
  /**
451
- * @default "public"
452
- *
453
- * @remarks
454
- * Not used by `@arcgis/api-extractor`. Present for completeness.
450
+ * To keep api.json size in check, `inheritedFrom` object does not include
451
+ * `viewUrl`.
455
452
  */
456
- privacy?: ApiPrivacy;
457
- };
453
+ inheritedFrom?: ApiReference;
454
+ }
458
455
  /**
459
456
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/slot
460
457
  */
461
- export type ApiSlot = {
458
+ export interface ApiSlot extends ApiWithDescription, ApiWithUnusedSummary {
462
459
  /**
463
460
  * The slot name, or the empty string for an unnamed slot.
464
461
  *
465
462
  * @example "header"
466
463
  */
467
464
  name: string;
468
- /**
469
- * A markdown summary suitable for display in a listing.
470
- *
471
- * @remarks
472
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
473
- * with custom-elements-manifest.
474
- */
475
- summary?: string;
476
- /**
477
- * A markdown description.
478
- */
479
- description?: string;
480
465
  /**
481
466
  * Whether the slot is deprecated.
482
467
  * If the value is a string, it's the reason for the deprecation.
483
468
  *
484
469
  * @default false
485
470
  *
486
- * @remarks
471
+ * @deprecated
487
472
  * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
488
473
  * with custom-elements-manifest.
489
474
  */
490
- deprecated?: boolean | string;
491
- };
475
+ deprecated?: string | true;
476
+ }
492
477
  /**
493
478
  * The description of exposed CSS Parts
494
479
  *
495
480
  * @see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_shadow_parts
496
481
  */
497
- export type ApiCssPart = {
482
+ export interface ApiCssPart extends ApiWithDescription, ApiWithUnusedSummary {
498
483
  /**
499
484
  * @example "tab"
500
485
  */
501
486
  name: string;
502
- /**
503
- * A markdown summary suitable for display in a listing.
504
- *
505
- * @remarks
506
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
507
- * with custom-elements-manifest.
508
- */
509
- summary?: string;
510
- /**
511
- * A markdown description.
512
- */
513
- description?: string;
514
487
  /**
515
488
  * Whether the CSS shadow part is deprecated.
516
489
  * If the value is a string, it's the reason for the deprecation.
517
490
  *
518
491
  * @default false
519
492
  *
520
- * @remarks
493
+ * @deprecated
521
494
  * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
522
495
  * with custom-elements-manifest.
523
496
  */
524
- deprecated?: boolean | string;
525
- };
497
+ deprecated?: string | true;
498
+ }
526
499
  /**
527
500
  * The description of a CSS Custom State.
528
501
  *
529
502
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet
530
503
  */
531
- export type ApiCssCustomState = {
504
+ export interface ApiCssCustomState extends ApiWithDescription, ApiWithUnusedSummary {
532
505
  /**
533
506
  * The name of the state. Note: Unlike CSS custom properties, custom states
534
507
  * do not have a leading `--`.
@@ -536,31 +509,19 @@ export type ApiCssCustomState = {
536
509
  * @example "active"
537
510
  */
538
511
  name: string;
539
- /**
540
- * A markdown summary suitable for display in a listing.
541
- *
542
- * @remarks
543
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
544
- * with custom-elements-manifest.
545
- */
546
- summary?: string;
547
- /**
548
- * A markdown description.
549
- */
550
- description?: string;
551
512
  /**
552
513
  * Whether the CSS custom state is deprecated.
553
514
  * If the value is a string, it's the reason for the deprecation.
554
515
  *
555
516
  * @default false
556
517
  *
557
- * @remarks
518
+ * @deprecated
558
519
  * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
559
520
  * with custom-elements-manifest.
560
521
  */
561
- deprecated?: boolean | string;
562
- };
563
- export type ApiCssCustomProperty = {
522
+ deprecated?: string | true;
523
+ }
524
+ export interface ApiCssCustomProperty extends ApiWithDescription, ApiWithUnusedSummary {
564
525
  /**
565
526
  * The name of the property, including leading `--`.
566
527
  *
@@ -580,34 +541,26 @@ export type ApiCssCustomProperty = {
580
541
  * "<length> | <percentage>": accepts lengths or percentages but not calc expressions with a combination of the two
581
542
  * "small | medium | large": accepts one of these values set as custom indents.
582
543
  * "*": any valid token
583
- */
584
- syntax?: string;
585
- default?: string;
586
- /**
587
- * A markdown summary suitable for display in a listing.
588
544
  *
589
- * @remarks
545
+ * @deprecated
590
546
  * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
591
547
  * with custom-elements-manifest.
592
548
  */
593
- summary?: string;
594
- /**
595
- * A markdown description.
596
- */
597
- description?: string;
549
+ syntax?: string;
550
+ default?: string;
598
551
  /**
599
552
  * Whether the CSS custom property is deprecated.
600
553
  * If the value is a string, it's the reason for the deprecation.
601
554
  *
602
555
  * @default false
603
556
  *
604
- * @remarks
557
+ * @deprecated
605
558
  * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
606
559
  * with custom-elements-manifest.
607
560
  */
608
- deprecated?: boolean | string;
609
- };
610
- export type ApiType = {
561
+ deprecated?: string | true;
562
+ }
563
+ export interface ApiType extends ApiWithUnusedSource {
611
564
  /**
612
565
  * The full string representation of the type, in whatever type syntax is
613
566
  * used, such as JSDoc, Closure, or TypeScript.
@@ -628,21 +581,52 @@ export type ApiType = {
628
581
  * and `BarElement` without understanding arrays, generics, or union types.
629
582
  */
630
583
  references?: ApiTypeReference[];
631
- /**
632
- * @remarks
633
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
634
- * with custom-elements-manifest.
635
- */
636
- source?: ApiSourceReference;
637
584
  /**
638
585
  * An enum of possible values for this type.
639
586
  *
640
587
  * @remarks
641
588
  * Not present in vanilla custom-elements-manifest.
589
+ *
590
+ * @privateRemarks
591
+ * FINAL: should we drop this field in favor of offering a util that infers
592
+ * type values from the type string?
593
+ *
594
+ * Pros:
595
+ * - smaller api.json
596
+ * - simpler implementation in some ways (don't need to keep type string and
597
+ * values in sync when doing post processing)
598
+ * - one less non-standard field
599
+ *
600
+ * Cons:
601
+ * - Lumina compiler at present relies on type values in several places, so
602
+ * it may have to compute this anyway
603
+ * - inferring it from the type string is not trivial, think of:
604
+ *
605
+ * ```ts
606
+ * type A = "a|\"" | { b: string | undefined } | T extends `a${1|2}b` ? X | Y : Z;
607
+ * ```
608
+ *
609
+ * though, ChatGPT one-shotted a working solution:
610
+ * https://chatgpt.com/share/68ccd574-2a8c-8003-a6cc-aa3ef01c40ad
611
+ *
612
+ * still, it will be a maintenance burden whenever new TS syntax is added
642
613
  */
643
614
  values?: ApiValue[];
644
- };
645
- export type ApiValue = {
615
+ }
616
+ export interface ApiWithUnusedSource {
617
+ /**
618
+ * A reference to the source of a declaration or member.
619
+ * An absolute URL to the source (ie. a GitHub URL).
620
+ *
621
+ * @deprecated
622
+ * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
623
+ * with custom-elements-manifest.
624
+ */
625
+ source?: {
626
+ href: string;
627
+ };
628
+ }
629
+ export interface ApiValue {
646
630
  /**
647
631
  * @example "string"
648
632
  */
@@ -651,7 +635,7 @@ export type ApiValue = {
651
635
  * @example "active"
652
636
  */
653
637
  value?: string;
654
- };
638
+ }
655
639
  /**
656
640
  * A reference that is associated with a type string and optionally a range
657
641
  * within the string.
@@ -661,31 +645,40 @@ export type ApiValue = {
661
645
  * type string is the symbol referenced and the name should match the type
662
646
  * string.
663
647
  */
664
- export type ApiTypeReference = ApiReference & {
648
+ export interface ApiTypeReference extends ApiReference {
665
649
  start?: number;
666
650
  end?: number;
667
- };
668
- /**
669
- * The common interface of classes and mixins.
670
- */
671
- export type ApiClassDeclaration = {
672
- kind: "class";
651
+ }
652
+ export interface ApiObjectLikeDeclaration extends ApiWithDescription, ApiWithDocsTags, ApiWithDeprecated, ApiWithUnusedSource, ApiWithUnusedSummary, ApiWithTypeParameters {
673
653
  /**
674
654
  * @example "ArcgisCounter"
675
655
  */
676
656
  name: string;
677
- /**
678
- * A markdown summary suitable for display in a listing.
679
- *
680
- * @remarks
681
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
682
- * with custom-elements-manifest.
683
- */
684
- summary?: string;
685
- /**
686
- * A markdown description of the class.
687
- */
688
- description?: string;
657
+ members?: ApiClassMember[];
658
+ }
659
+ export interface ApiWithTypeParameters {
660
+ typeParameters?: ApiTypeParameter[];
661
+ }
662
+ /**
663
+ * @remarks
664
+ * Not present in vanilla custom-elements-manifest.
665
+ */
666
+ export interface ApiTypeParameter {
667
+ name: string;
668
+ constraint?: ApiType;
669
+ default?: ApiType;
670
+ /** @default false */
671
+ const?: true;
672
+ /** @default false */
673
+ in?: true;
674
+ /** @default false */
675
+ out?: true;
676
+ }
677
+ /**
678
+ * The common interface of classes and mixins.
679
+ */
680
+ export interface ApiClassDeclaration extends ApiObjectLikeDeclaration, ApiWithEvents {
681
+ kind: "class";
689
682
  /**
690
683
  * The superclass of this class.
691
684
  *
@@ -693,7 +686,7 @@ export type ApiClassDeclaration = {
693
686
  * includes the mixin applications and the true superclass is computed
694
687
  * from them.
695
688
  */
696
- superclass?: ApiReference;
689
+ superclass?: ApiReferenceWithTypeArguments;
697
690
  /**
698
691
  * Any class mixins applied in the extends clause of this class.
699
692
  *
@@ -706,133 +699,92 @@ export type ApiClassDeclaration = {
706
699
  * matches the order of language used to describe mixin application, like
707
700
  * "S with A, B".
708
701
  *
709
- * @example
710
- *
711
- * ```javascript
712
- * class T extends B(A(S)) {}
713
- * ```
714
- *
715
- * is described by:
716
- * ```json
717
- * {
718
- * "kind": "class",
719
- * "superclass": {
720
- * "name": "S"
721
- * },
722
- * "mixins": [
723
- * {
724
- * "name": "A"
725
- * },
726
- * {
727
- * "name": "B"
728
- * },
729
- * ]
730
- * }
731
- * ```
702
+ * @see https://webgis.esri.com/webgis/core/core/mixins
732
703
  *
733
- * @remarks
734
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
735
- * with custom-elements-manifest.
736
704
  */
737
- mixins?: ApiReference[];
738
- members?: ApiClassMember[];
705
+ mixins?: ApiReferenceWithTypeArguments[];
706
+ }
707
+ export interface ApiWithEvents {
739
708
  /**
740
- * @remarks
741
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
742
- * with custom-elements-manifest.
709
+ * The events that this object fires.
743
710
  */
744
- source?: ApiSourceReference;
711
+ events?: ApiEvent[];
712
+ }
713
+ /**
714
+ * An interface that describes the properties and methods of an object.
715
+ *
716
+ * @remarks
717
+ * Not yet part of vanilla custom-elements-manifest, but may be added in the
718
+ * future. See https://github.com/webcomponents/custom-elements-manifest/pull/77
719
+ */
720
+ export interface ApiInterfaceDeclaration extends ApiObjectLikeDeclaration {
721
+ kind: "interface";
745
722
  /**
746
- * Whether the class or mixin is deprecated.
747
- * If the value is a string, it's the reason for the deprecation.
748
- *
749
- * @default false
723
+ * The interfaces that this interface extends.
750
724
  */
751
- deprecated?: boolean | string;
725
+ supertypes?: ApiReferenceWithTypeArguments[];
752
726
  /**
753
- * @default "public"
754
- *
755
- * @remarks
756
- * Not used by `@arcgis/api-extractor`. Present for completeness.
727
+ * Present in type aliases only. If type alias is an intersection, then type
728
+ * reference members will be represented in the `supertypes` field. If type
729
+ * alias is an object literal, then object members will be represented in
730
+ * the `members` field. Thus, the `type` field will only be used for unions,
731
+ * mapped types, conditional types, and other types that cannot be represented
732
+ * as supertypes/members.
757
733
  */
758
- privacy?: ApiPrivacy;
759
- };
760
- export type ApiClassMember = ApiClassField | ApiClassMethod;
734
+ type?: ApiType;
735
+ }
736
+ export type ApiClassMember = ApiClassCallSignature | ApiClassConstructor | ApiClassField | ApiClassMethod;
761
737
  export type ApiCustomElementMember = ApiClassMethod | ApiCustomElementField;
762
738
  /**
763
739
  * The common interface of variables, class fields, and function
764
740
  * parameters.
765
741
  */
766
- export type ApiPropertyLike = {
742
+ export interface ApiPropertyLike extends ApiWithDescription, ApiWithDocsTags, ApiWithDeprecated, ApiWithUnusedSummary {
767
743
  /**
768
744
  * @example "initialCount"
745
+ * @example Special names appear unquoted and unescaped: "@eventTypes"
746
+ * @example Computed Symbol properties appear as "[Symbol.iterator]"
769
747
  */
770
748
  name: string;
771
- /**
772
- * A markdown summary suitable for display in a listing.
773
- *
774
- * @remarks
775
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
776
- * with custom-elements-manifest.
777
- */
778
- summary?: string;
779
- /**
780
- * A markdown description of the field.
781
- */
782
- description?: string;
783
749
  type: ApiType;
784
750
  /**
785
751
  * @example 10
786
752
  */
787
753
  default?: string;
788
- /**
789
- * Whether the property is deprecated.
790
- * If the value is a string, it's the reason for the deprecation.
791
- *
792
- * @default false
793
- */
794
- deprecated?: boolean | string;
754
+ }
755
+ export interface ApiClassField extends ApiPropertyLike, ApiWithInheritance, ApiWithStatic, ApiWithPrivacy, ApiWithUnusedSource {
756
+ kind: "field";
795
757
  /**
796
758
  * Whether the property is read-only.
797
759
  *
798
760
  * @default false
799
761
  */
800
- readonly?: boolean;
801
- };
802
- export type ApiClassField = ApiPropertyLike & {
803
- kind: "field";
762
+ readonly?: true;
804
763
  /**
805
- * @default false
764
+ * Getter type if any.
806
765
  *
807
- * @remarks
808
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
809
- * with custom-elements-manifest.
766
+ * This property will only be set if it differs from `type` property in order
767
+ * to keep documentation UI cleaner, and api.json smaller.
810
768
  *
811
- * All static members are excluded from the api.json.
812
- */
813
- static?: boolean;
814
- /**
815
- * @default "public"
769
+ * If property is read-only, only the `type` property will be set.
816
770
  *
817
- * @remarks
818
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
819
- * with custom-elements-manifest.
771
+ * @default undefined
820
772
  *
821
- * All private and protected fields are excluded from the api.json.
773
+ * @remarks
774
+ * Not present in vanilla custom-elements-manifest.
822
775
  */
823
- privacy?: ApiPrivacy;
824
- inheritedFrom?: ApiReference;
776
+ getterType?: ApiType;
777
+ }
778
+ export interface ApiWithStatic {
825
779
  /**
826
- * @remarks
827
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
828
- * with custom-elements-manifest.
780
+ * @default false
829
781
  */
830
- source?: ApiSourceReference;
831
- };
782
+ static?: true;
783
+ }
832
784
  /**
833
785
  * Additional metadata for fields on custom elements.
834
786
  */
835
- export type ApiCustomElementField = ApiClassField & {
787
+ export interface ApiCustomElementField extends ApiClassField {
836
788
  /**
837
789
  * The corresponding attribute name if there is one.
838
790
  *
@@ -849,22 +801,7 @@ export type ApiCustomElementField = ApiClassField & {
849
801
  *
850
802
  * @default false
851
803
  */
852
- reflects?: boolean;
853
- /**
854
- * @remarks
855
- * Not present in vanilla custom-elements-manifest.
856
- */
857
- docsTags?: ApiDocsTag[];
858
- /**
859
- * If getter type differs from setter type, this property will
860
- * contain the getter type.
861
- *
862
- * @default undefined
863
- *
864
- * @remarks
865
- * Not present in vanilla custom-elements-manifest.
866
- */
867
- getterType?: Pick<ApiType, "text">;
804
+ reflects?: true;
868
805
  /**
869
806
  * For some properties, we show them as read-only in the docs and in the
870
807
  * typings but don't actually enforce read-only at runtime.
@@ -879,214 +816,109 @@ export type ApiCustomElementField = ApiClassField & {
879
816
  * @remarks
880
817
  * Not present in vanilla custom-elements-manifest.
881
818
  */
882
- docsOnlyReadonly?: boolean;
883
- };
884
- export type ApiClassMethod = ApiFunctionLike & {
819
+ docsOnlyReadonly?: true;
820
+ }
821
+ export interface ApiClassMethod extends ApiFunctionLike, ApiWithInheritance, ApiWithStatic, ApiWithPrivacy, ApiWithUnusedSource {
885
822
  kind: "method";
886
823
  /**
887
824
  * @default false
888
- *
889
- * @remarks
890
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
891
- * with custom-elements-manifest.
892
- *
893
- * All static members are excluded from the api.json.
894
- */
895
- static?: boolean;
896
- /**
897
- * @default "public"
898
- *
899
- * @remarks
900
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
901
- * with custom-elements-manifest.
902
- *
903
- * All private and protected fields are excluded from the api.json.
904
825
  */
905
- privacy?: ApiPrivacy;
906
- inheritedFrom?: ApiReference;
907
- /**
908
- * @remarks
909
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
910
- * with custom-elements-manifest.
911
- */
912
- source?: ApiSourceReference;
913
- /**
914
- * @remarks
915
- * Not present in vanilla custom-elements-manifest.
916
- */
917
- docsTags?: ApiDocsTag[];
826
+ static?: true;
918
827
  /**
828
+ * @example "(options?: __esri.PopupViewOpenPopupOptions): Promise<void>"
829
+ * @deprecated
830
+ * If documentation UI shows a table with parameters and the return type, then
831
+ * displaying the signature is redundant.
832
+ * Still, if needed, you can use printSignature() util from
833
+ * `@arcgis/api-extractor`.
919
834
  * @remarks
920
835
  * Not present in vanilla custom-elements-manifest.
921
836
  */
922
837
  signature: string;
923
- /**
924
- * @default false
925
- *
926
- * @remarks
927
- * Not present in vanilla custom-elements-manifest.
928
- */
929
- async?: boolean;
930
- };
838
+ }
931
839
  /**
932
- * A description of a class mixin.
933
- *
934
- * Mixins are functions which generate a new subclass of a given superclass.
935
- * This interfaces describes the class and custom element features that
936
- * are added by the mixin. As such, it extends the CustomElement interface and
937
- * ClassLike interface.
938
- *
939
- * Since mixins are functions, it also extends the FunctionLike interface. This
940
- * means a mixin is callable, and has parameters and a return type.
941
- *
942
- * The return type is often hard or impossible to accurately describe in type
943
- * systems like TypeScript. It requires generics and an `extends` operator
944
- * that TypeScript lacks. Therefore it's recommended that the return type is
945
- * left empty. The most common form of a mixin function takes a single
946
- * argument, so consumers of this interface should assume that the return type
947
- * is the single argument subclassed by this declaration.
948
- *
949
- * A mixin should not have a superclass. If a mixins composes other mixins,
950
- * they should be listed in the `mixins` field.
951
- *
952
- * See more information on the class mixin pattern in JavaScript:
953
- * https://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/
954
- *
955
- * @example
956
- *
957
- * This JavaScript mixin declaration:
958
- * ```javascript
959
- * const MyMixin = (base) => class extends base {
960
- * foo() { ... }
961
- * }
962
- * ```
963
- *
964
- * Is described by this JSON:
965
- * ```json
966
- * {
967
- * "kind": "mixin",
968
- * "name": "MyMixin",
969
- * "parameters": [
970
- * {
971
- * "name": "base",
972
- * }
973
- * ],
974
- * "members": [
975
- * {
976
- * "kind": "method",
977
- * "name": "foo",
978
- * }
979
- * ]
980
- * }
981
- * ```
982
- *
983
840
  * @remarks
984
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
985
- * with custom-elements-manifest.
841
+ * Not present in vanilla custom-elements-manifest.
986
842
  */
987
- export type ApiMixinDeclaration = ApiClassDeclaration & ApiFunctionLike & {
988
- kind: "mixin";
989
- };
843
+ export interface ApiClassConstructor extends Omit<ApiFunctionLike, "name" | "return">, ApiWithInheritance, ApiWithPrivacy {
844
+ kind: "constructor";
845
+ }
990
846
  /**
991
- * A class mixin that also adds custom element related properties.
992
- *
993
847
  * @remarks
994
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
995
- * with custom-elements-manifest.
848
+ * Not present in vanilla custom-elements-manifest.
996
849
  */
997
- export type ApiCustomElementMixinDeclaration = ApiCustomElementDeclaration & ApiMixinDeclaration;
850
+ export interface ApiClassCallSignature extends Omit<ApiFunctionLike, "name">, ApiWithInheritance, ApiWithPrivacy {
851
+ kind: "call-signature";
852
+ }
998
853
  /**
999
- * @remarks
1000
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
1001
- * with custom-elements-manifest.
854
+ * A description of a class mixin.
855
+ *
856
+ * @see https://webgis.esri.com/webgis/core/core/mixins
1002
857
  */
1003
- export type ApiVariableDeclaration = ApiPropertyLike & {
1004
- kind: "variable";
1005
- source?: ApiSourceReference;
1006
- };
858
+ export interface ApiMixinDeclaration extends Omit<ApiFunctionLike, "return">, ApiObjectLikeDeclaration, ApiWithEvents {
859
+ kind: "mixin";
860
+ /**
861
+ * The mixins that this mixin uses, if any.
862
+ */
863
+ mixins?: ApiReferenceWithTypeArguments[];
864
+ /**
865
+ * @deprecated
866
+ * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
867
+ * with custom-elements-manifest.
868
+ */
869
+ return?: ApiFunctionLikeReturn;
870
+ }
1007
871
  /**
1008
- * @remarks
872
+ * A class mixin that also adds custom element related properties.
873
+ *
874
+ * @deprecated
1009
875
  * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
1010
876
  * with custom-elements-manifest.
1011
877
  */
1012
- export type ApiFunctionDeclaration = ApiFunctionLike & {
878
+ export interface ApiCustomElementMixinDeclaration extends Omit<ApiCustomElementDeclaration, "kind">, Omit<ApiMixinDeclaration, "members"> {
879
+ }
880
+ export interface ApiVariableDeclaration extends ApiPropertyLike, ApiWithUnusedSource {
881
+ kind: "variable";
882
+ }
883
+ export interface ApiFunctionDeclaration extends ApiFunctionLike, ApiWithUnusedSource {
1013
884
  kind: "function";
1014
- source?: ApiSourceReference;
1015
- };
1016
- export type ApiParameter = ApiPropertyLike & {
885
+ }
886
+ export interface ApiParameter extends ApiPropertyLike {
1017
887
  /**
1018
888
  * Whether the parameter is optional.
1019
889
  *
1020
890
  * @default false
1021
891
  */
1022
- optional?: boolean;
892
+ optional?: true;
1023
893
  /**
1024
894
  * @default false
1025
895
  *
1026
896
  * Whether the parameter is a rest parameter. Only the last parameter may be a rest parameter.
1027
897
  * Undefined implies single parameter.
1028
898
  */
1029
- rest?: boolean;
1030
- };
1031
- export type ApiFunctionLike = {
899
+ rest?: true;
900
+ }
901
+ export interface ApiFunctionLike extends ApiWithDescription, ApiWithDocsTags, ApiWithDeprecated, ApiWithUnusedSummary, ApiWithTypeParameters {
1032
902
  /**
1033
903
  * @example "increment"
904
+ * @example Special names appear unquoted and unescaped: "@eventTypes"
905
+ * @example Computed Symbol properties appear as "[Symbol.iterator]"
1034
906
  */
1035
907
  name: string;
1036
- /**
1037
- * A markdown summary suitable for display in a listing.
1038
- *
1039
- * @remarks
1040
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
1041
- * with custom-elements-manifest.
1042
- */
1043
- summary?: string;
1044
- /**
1045
- * A markdown description.
1046
- */
1047
- description?: string;
1048
- /**
1049
- * Whether the function is deprecated.
1050
- * If the value is a string, it's the reason for the deprecation.
1051
- *
1052
- * @default false
1053
- */
1054
- deprecated?: boolean | string;
1055
908
  /**
1056
909
  * @default []
1057
910
  */
1058
911
  parameters?: ApiParameter[];
1059
- return?: {
1060
- type?: ApiType;
1061
- /**
1062
- * A markdown summary suitable for display in a listing.
1063
- *
1064
- * @remarks
1065
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
1066
- * with custom-elements-manifest.
1067
- */
1068
- summary?: string;
1069
- /**
1070
- * A markdown description.
1071
- */
1072
- description?: string;
1073
- };
1074
- };
1075
- /**
1076
- * @remarks
1077
- * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
1078
- * with custom-elements-manifest.
1079
- */
1080
- export type ApiPrivacy = "private" | "protected" | "public";
1081
- export type ApiDemo = {
1082
- /**
1083
- * A markdown description of the demo.
1084
- */
1085
- description: string;
912
+ return: ApiFunctionLikeReturn;
913
+ }
914
+ export interface ApiFunctionLikeReturn extends ApiWithDescription, ApiWithUnusedSummary {
915
+ type: ApiType;
916
+ }
917
+ export interface ApiDemo extends ApiWithUnusedSource {
1086
918
  /**
1087
919
  * Relative URL of the demo if it's published with the package. Absolute URL
1088
920
  * if it's hosted.
1089
921
  */
1090
922
  url: string;
1091
- source?: ApiSourceReference;
1092
- };
923
+ description: NonNullable<ApiWithDescription["description"]>;
924
+ }