@workday/canvas-kit-docs 9.0.0-alpha.368-next.6 → 9.0.0-alpha.382-next.2

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.
Files changed (57) hide show
  1. package/dist/es6/docgen/createTraversals.js +41 -22
  2. package/dist/es6/docgen/docParser.js +285 -257
  3. package/dist/es6/docgen/getExternalSymbol.js +2 -2
  4. package/dist/es6/docgen/plugins/componentParser.js +28 -33
  5. package/dist/es6/docgen/plugins/enhancedComponentParser.js +211 -150
  6. package/dist/es6/docgen/plugins/modelParser.js +139 -79
  7. package/dist/es6/docgen/traversals.js +396 -397
  8. package/dist/es6/docgen/traverse.js +8 -9
  9. package/dist/es6/lib/DescriptionTooltip.js +1 -1
  10. package/dist/es6/lib/MDXElements.js +13 -39
  11. package/dist/es6/lib/MoreTooltip.js +21 -41
  12. package/dist/es6/lib/Specifications.js +30 -34
  13. package/dist/es6/lib/StylePropsTable.js +8 -9
  14. package/dist/es6/lib/Table.js +19 -30
  15. package/dist/es6/lib/Value.js +13 -17
  16. package/dist/es6/lib/docs.js +701 -397
  17. package/dist/es6/lib/widgetUtils.js +44 -76
  18. package/dist/es6/lib/widgets/array.js +1 -2
  19. package/dist/es6/lib/widgets/callExpression.js +4 -5
  20. package/dist/es6/lib/widgets/canvasColor.js +2 -2
  21. package/dist/es6/lib/widgets/component.js +1 -2
  22. package/dist/es6/lib/widgets/conditional.js +1 -2
  23. package/dist/es6/lib/widgets/enhancedComponent.js +19 -24
  24. package/dist/es6/lib/widgets/external.js +1 -4
  25. package/dist/es6/lib/widgets/function.js +5 -7
  26. package/dist/es6/lib/widgets/intersection.js +3 -4
  27. package/dist/es6/lib/widgets/model.js +4 -6
  28. package/dist/es6/lib/widgets/object.js +2 -3
  29. package/dist/es6/lib/widgets/parenthesis.js +1 -2
  30. package/dist/es6/lib/widgets/primitives.js +17 -39
  31. package/dist/es6/lib/widgets/qualifiedName.js +1 -2
  32. package/dist/es6/lib/widgets/symbol.js +1 -2
  33. package/dist/es6/lib/widgets/tuple.js +2 -3
  34. package/dist/es6/lib/widgets/typeParameter.js +1 -2
  35. package/dist/es6/lib/widgets/union.js +3 -4
  36. package/dist/es6/mdx/installBlock.js +6 -7
  37. package/dist/es6/mdx/style-props/examples/Background.js +5 -16
  38. package/dist/es6/mdx/style-props/examples/Border.js +5 -16
  39. package/dist/es6/mdx/style-props/examples/Color.js +5 -16
  40. package/dist/es6/mdx/style-props/examples/Depth.js +5 -16
  41. package/dist/es6/mdx/style-props/examples/Flex.js +11 -22
  42. package/dist/es6/mdx/style-props/examples/FlexItem.js +10 -21
  43. package/dist/es6/mdx/style-props/examples/Grid.js +6 -17
  44. package/dist/es6/mdx/style-props/examples/GridItem.js +6 -17
  45. package/dist/es6/mdx/style-props/examples/Layout.js +5 -16
  46. package/dist/es6/mdx/style-props/examples/Other.js +5 -16
  47. package/dist/es6/mdx/style-props/examples/Position.js +5 -16
  48. package/dist/es6/mdx/style-props/examples/Space.js +6 -17
  49. package/dist/es6/mdx/style-props/examples/Text.js +2 -2
  50. package/dist/es6/mdx/welcomePage.js +3 -3
  51. package/dist/mdx/9.0-UPGRADE-GUIDE.mdx +30 -3
  52. package/dist/mdx/preview-react/text-area/examples/Alert.tsx +1 -1
  53. package/dist/mdx/preview-react/text-input/examples/Alert.tsx +1 -1
  54. package/dist/mdx/preview-react/text-input/examples/ThemedAlert.tsx +5 -2
  55. package/dist/mdx/react/banner/examples/StickyAnimation.tsx +7 -5
  56. package/dist/mdx/react/common/examples/ResponsiveViewport.tsx +2 -3
  57. package/package.json +5 -5
@@ -1,20 +1,8 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
1
  import ts from 'typescript';
13
2
  import { getExternalSymbol } from './getExternalSymbol';
14
3
  import t, { find } from './traverse';
15
- var DocParser = /** @class */ (function () {
16
- function DocParser(program, plugins) {
17
- if (plugins === void 0) { plugins = []; }
4
+ export class DocParser {
5
+ constructor(program, plugins = []) {
18
6
  this.program = program;
19
7
  this.plugins = plugins;
20
8
  /**
@@ -28,14 +16,13 @@ var DocParser = /** @class */ (function () {
28
16
  /**
29
17
  * Get all {@link ExportedSymbol}s from a file.
30
18
  */
31
- DocParser.prototype.getExportedSymbols = function (fileName) {
32
- var _this = this;
33
- var symbols = [];
34
- var sourceFile = this.program.getSourceFile(fileName);
19
+ getExportedSymbols(fileName) {
20
+ const symbols = [];
21
+ const sourceFile = this.program.getSourceFile(fileName);
35
22
  if (!sourceFile)
36
23
  return symbols;
37
- find(sourceFile, function (node) {
38
- var kind = node.kind;
24
+ find(sourceFile, node => {
25
+ const kind = node.kind;
39
26
  return ([
40
27
  'VariableDeclaration',
41
28
  'InterfaceDeclaration',
@@ -44,35 +31,38 @@ var DocParser = /** @class */ (function () {
44
31
  'EnumDeclaration',
45
32
  'ClassDeclaration',
46
33
  ]
47
- .map(function (k) { return ts.SyntaxKind[k]; })
48
- .includes(kind) && isNodeExported(_this.checker, node));
49
- }).forEach(function (node) {
50
- var symbol = getSymbolFromNode(_this.checker, node);
51
- var previousSymbolsLength = _this.symbols.length;
34
+ .map(k => ts.SyntaxKind[k])
35
+ .includes(kind) && isNodeExported(this.checker, node));
36
+ }).forEach(node => {
37
+ const symbol = getSymbolFromNode(this.checker, node);
38
+ const previousSymbolsLength = this.symbols.length;
52
39
  if (symbol) {
53
- var exportedSymbol = __assign(__assign({ name: symbol.name, fileName: fileName }, findDocComment(_this.checker, symbol)), { type: _this.getValueFromNode(node) });
40
+ const exportedSymbol = {
41
+ name: symbol.name,
42
+ fileName,
43
+ ...findDocComment(this.checker, symbol),
44
+ type: this.getValueFromNode(node),
45
+ };
54
46
  symbols.push(exportedSymbol);
55
- var addedSymbolsLength = previousSymbolsLength - _this.symbols.length;
47
+ const addedSymbolsLength = previousSymbolsLength - this.symbols.length;
56
48
  // add all symbols added by the parser
57
49
  if (addedSymbolsLength) {
58
- _this.symbols.slice(addedSymbolsLength).forEach(function (symbol) {
50
+ this.symbols.slice(addedSymbolsLength).forEach(symbol => {
59
51
  symbols.push(symbol);
60
52
  });
61
53
  }
62
- _this.symbols.push(exportedSymbol);
54
+ this.symbols.push(exportedSymbol);
63
55
  }
64
56
  });
65
57
  return symbols;
66
- };
67
- DocParser.prototype.getValueFromNode = function (node) {
58
+ }
59
+ getValueFromNode(node) {
68
60
  return getValueFromNode(this, node);
69
- };
70
- DocParser.prototype.getValueFromType = function (type, node) {
61
+ }
62
+ getValueFromType(type, node) {
71
63
  return getValueFromType(this, type, node);
72
- };
73
- return DocParser;
74
- }());
75
- export { DocParser };
64
+ }
65
+ }
76
66
  /**
77
67
  * This is the main recursive function for creating docs from the Typescript AST. The AST is
78
68
  * traversed and type information is extracted from source code. The Typescript type checker is used
@@ -90,7 +80,7 @@ function getValueFromNode(parser, node) {
90
80
  // This shouldn't happen, but we'd rather see `???` in the output than crash
91
81
  return unknownValue('???');
92
82
  }
93
- return (parser.plugins.reduce(function (result, fn) {
83
+ return (parser.plugins.reduce((result, fn) => {
94
84
  return result || fn(node, parser);
95
85
  }, undefined) || _getValueFromNode(parser, node));
96
86
  }
@@ -99,7 +89,7 @@ function getValueFromNode(parser, node) {
99
89
  */
100
90
  function _getValueFromNode(parser, node) {
101
91
  var _a, _b, _c, _d, _e, _f;
102
- var checker = parser.checker;
92
+ const { checker } = parser;
103
93
  // Uncomment for debugging
104
94
  // console.log(
105
95
  // t.getKindNameFromNode(node) || node.kind,
@@ -119,7 +109,7 @@ function _getValueFromNode(parser, node) {
119
109
  if (t.isTupleType(node)) {
120
110
  return {
121
111
  kind: 'tuple',
122
- value: node.elements.map(function (e) { return getValueFromNode(parser, e); }),
112
+ value: node.elements.map(e => getValueFromNode(parser, e)),
123
113
  };
124
114
  }
125
115
  /**
@@ -140,22 +130,22 @@ function _getValueFromNode(parser, node) {
140
130
  if ((t.isTypeAliasDeclaration(node) && t.isTypeLiteral(node.type)) ||
141
131
  t.isInterfaceDeclaration(node)) {
142
132
  // Treat Interfaces and Types with TypeLiterals as interfaces
143
- var type = checker.getTypeAtLocation(node);
144
- var properties = type
133
+ const type = checker.getTypeAtLocation(node);
134
+ const properties = type
145
135
  .getProperties()
146
- .map(function (p) {
136
+ .map(p => {
147
137
  return getValueFromNode(parser, getValueDeclaration(p));
148
138
  })
149
139
  .filter(filterObjectProperties);
150
140
  // get index signature...
151
- var indexType = getIndexSignatureFromType(parser, type);
141
+ const indexType = getIndexSignatureFromType(parser, type);
152
142
  if (isObject(type) && (properties.length || indexType)) {
153
- var typeParameters = (_a = (node.typeParameters ||
154
- node.parent.typeParameters)) === null || _a === void 0 ? void 0 : _a.map(function (p) { return getValueFromNode(parser, p); });
143
+ const typeParameters = (_a = (node.typeParameters ||
144
+ node.parent.typeParameters)) === null || _a === void 0 ? void 0 : _a.map(p => getValueFromNode(parser, p));
155
145
  return {
156
146
  kind: 'object',
157
- properties: properties,
158
- typeParameters: typeParameters,
147
+ properties,
148
+ typeParameters,
159
149
  indexSignature: indexType,
160
150
  };
161
151
  }
@@ -176,7 +166,7 @@ function _getValueFromNode(parser, node) {
176
166
  * ```
177
167
  */
178
168
  if (t.isTypeAliasDeclaration(node)) {
179
- var typeParameters = (_b = node.typeParameters) === null || _b === void 0 ? void 0 : _b.map(function (p) { return getValueFromNode(parser, p); });
169
+ const typeParameters = (_b = node.typeParameters) === null || _b === void 0 ? void 0 : _b.map(p => getValueFromNode(parser, p));
180
170
  // We need to test if the `node.type` is a TypeReference and if that TypeReference is an exported
181
171
  // symbol. If the TypeReference is exported, we can continue with recursing on the `node.type`. If
182
172
  // it is not an exported symbol, we need to instead evaluate the type of the declaration directly using
@@ -190,15 +180,15 @@ function _getValueFromNode(parser, node) {
190
180
  // ```
191
181
  // If `ValueOf` was exported, the type would be documented as `ValueOf<{a: 'first', b:
192
182
  // 'second'}>`, but if it isn't exported, the value is `'first' | 'second'`
193
- var isLocalTypeReference = t.isTypeReference(node.type) && !isExportedSymbol(checker, node.type.typeName);
194
- var value = isLocalTypeReference
183
+ const isLocalTypeReference = t.isTypeReference(node.type) && !isExportedSymbol(checker, node.type.typeName);
184
+ const value = isLocalTypeReference
195
185
  ? getValueFromType(parser, checker.getTypeAtLocation(node), node) ||
196
186
  unknownValue(safeGetText(checker, node))
197
187
  : getValueFromNode(parser, node.type);
198
188
  return {
199
189
  kind: 'type',
200
190
  typeParameters: typeParameters || [],
201
- value: value,
191
+ value,
202
192
  };
203
193
  }
204
194
  /**
@@ -208,10 +198,10 @@ function _getValueFromNode(parser, node) {
208
198
  * ```
209
199
  */
210
200
  if (t.isClassDeclaration(node)) {
211
- var type = checker.getTypeAtLocation(node);
212
- var value = getObjectValueFromType(parser, type);
201
+ const type = checker.getTypeAtLocation(node);
202
+ const value = getObjectValueFromType(parser, type);
213
203
  if (value.kind === 'object') {
214
- value.typeParameters = (_c = node.typeParameters) === null || _c === void 0 ? void 0 : _c.map(function (p) {
204
+ value.typeParameters = (_c = node.typeParameters) === null || _c === void 0 ? void 0 : _c.map(p => {
215
205
  return getValueFromNode(parser, p);
216
206
  }).filter(filterObjectTypeParameters);
217
207
  }
@@ -231,12 +221,12 @@ function _getValueFromNode(parser, node) {
231
221
  * In this example, the TypeLiteral is `{ C: 'c' }`.
232
222
  */
233
223
  if (t.isTypeLiteral(node)) {
234
- var properties = node.members
235
- .map(function (member) {
224
+ const properties = node.members
225
+ .map(member => {
236
226
  return getValueFromNode(parser, member);
237
227
  })
238
228
  .filter(filterObjectProperties);
239
- return { kind: 'object', properties: properties };
229
+ return { kind: 'object', properties };
240
230
  }
241
231
  /**
242
232
  * A ArrayType is a special notation for arrays. For example:
@@ -265,13 +255,13 @@ function _getValueFromNode(parser, node) {
265
255
  * The constraint is `string` and the default is `'a'`
266
256
  */
267
257
  if (t.isTypeParameter(node)) {
268
- var constraint = node.constraint ? getValueFromNode(parser, node.constraint) : undefined;
269
- var defaultValue = node.default ? getValueFromNode(parser, node.default) : undefined;
258
+ const constraint = node.constraint ? getValueFromNode(parser, node.constraint) : undefined;
259
+ const defaultValue = node.default ? getValueFromNode(parser, node.default) : undefined;
270
260
  return {
271
261
  kind: 'typeParameter',
272
262
  name: node.name.text,
273
- defaultValue: defaultValue,
274
- constraint: constraint,
263
+ defaultValue,
264
+ constraint,
275
265
  required: !defaultValue,
276
266
  };
277
267
  }
@@ -295,13 +285,19 @@ function _getValueFromNode(parser, node) {
295
285
  * as a `parameter` instead of a `function`
296
286
  */
297
287
  if (t.isMethodDeclaration(node)) {
298
- var signature = getValueFromSignatureNode(parser, node);
299
- var symbol_1 = getSymbolFromNode(checker, node);
300
- var type = checker.getTypeAtLocation(node);
301
- var jsDoc = findDocComment(checker, symbol_1);
288
+ const signature = getValueFromSignatureNode(parser, node);
289
+ const symbol = getSymbolFromNode(checker, node);
290
+ const type = checker.getTypeAtLocation(node);
291
+ const jsDoc = findDocComment(checker, symbol);
302
292
  if (jsDoc.tags.default) {
303
293
  }
304
- return __assign({ kind: 'property', name: (symbol_1 === null || symbol_1 === void 0 ? void 0 : symbol_1.name) || '', type: signature, required: symbol_1 ? !isOptional(symbol_1) && !includesUndefined(type) : false }, jsDoc);
294
+ return {
295
+ kind: 'property',
296
+ name: (symbol === null || symbol === void 0 ? void 0 : symbol.name) || '',
297
+ type: signature,
298
+ required: symbol ? !isOptional(symbol) && !includesUndefined(type) : false,
299
+ ...jsDoc,
300
+ };
305
301
  }
306
302
  /**
307
303
  * A MethodSignature is a type of property declaration within a TS type. It is a special syntax
@@ -321,17 +317,22 @@ function _getValueFromNode(parser, node) {
321
317
  * of a `function`.
322
318
  */
323
319
  if (t.isMethodSignature(node)) {
324
- var signature = getValueFromSignatureNode(parser, node);
325
- var symbol_2 = getSymbolFromNode(checker, node);
326
- var jsDoc = findDocComment(checker, symbol_2);
327
- return __assign({ kind: 'property', name: (symbol_2 === null || symbol_2 === void 0 ? void 0 : symbol_2.name) || node.name.text || '', type: signature }, jsDoc);
320
+ const signature = getValueFromSignatureNode(parser, node);
321
+ const symbol = getSymbolFromNode(checker, node);
322
+ const jsDoc = findDocComment(checker, symbol);
323
+ return {
324
+ kind: 'property',
325
+ name: (symbol === null || symbol === void 0 ? void 0 : symbol.name) || node.name.text || '',
326
+ type: signature,
327
+ ...jsDoc,
328
+ };
328
329
  }
329
330
  /**
330
331
  * A FunctionType is a function declaration in Typescript's type annotation
331
332
  */
332
333
  if (t.isFunctionType(node)) {
333
- var declaration = node;
334
- var signature = checker.getSignatureFromDeclaration(declaration);
334
+ const declaration = node;
335
+ const signature = checker.getSignatureFromDeclaration(declaration);
335
336
  if (signature) {
336
337
  return getValueFromSignature(parser, node, signature);
337
338
  }
@@ -368,11 +369,11 @@ function _getValueFromNode(parser, node) {
368
369
  if (node.initializer &&
369
370
  t.isIdentifier(node.initializer) &&
370
371
  isExportedSymbol(checker, node.initializer)) {
371
- var symbol_3 = getSymbolFromNode(checker, node.initializer);
372
+ const symbol = getSymbolFromNode(checker, node.initializer);
372
373
  return {
373
374
  kind: 'symbol',
374
375
  name: node.initializer.text,
375
- fileName: (_d = symbol_3 === null || symbol_3 === void 0 ? void 0 : symbol_3.valueDeclaration) === null || _d === void 0 ? void 0 : _d.getSourceFile().fileName,
376
+ fileName: (_d = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) === null || _d === void 0 ? void 0 : _d.getSourceFile().fileName,
376
377
  };
377
378
  }
378
379
  if (node.initializer && ts.isFunctionLike(node.initializer)) {
@@ -380,7 +381,7 @@ function _getValueFromNode(parser, node) {
380
381
  }
381
382
  // We have no type information in the AST. We'll get the Type from the type checker and run some
382
383
  // tests on what we have
383
- var type = checker.getTypeAtLocation(node.initializer || node);
384
+ const type = checker.getTypeAtLocation(node.initializer || node);
384
385
  // Both functions and objects are considered objects to Typescript
385
386
  if (isObject(type)) {
386
387
  if (type.objectFlags & ts.ObjectFlags.ArrayLiteral) {
@@ -388,7 +389,7 @@ function _getValueFromNode(parser, node) {
388
389
  }
389
390
  return getObjectValueFromType(parser, type);
390
391
  }
391
- var value = getValueFromType(parser, type);
392
+ const value = getValueFromType(parser, type);
392
393
  if (value)
393
394
  return value;
394
395
  }
@@ -401,18 +402,24 @@ function _getValueFromNode(parser, node) {
401
402
  * }
402
403
  */
403
404
  if (t.isPropertySignature(node)) {
404
- var symbol_4 = getSymbolFromNode(checker, node);
405
- var jsDoc = findDocComment(checker, symbol_4);
405
+ const symbol = getSymbolFromNode(checker, node);
406
+ const jsDoc = findDocComment(checker, symbol);
406
407
  // Get the name of the property - it could be a symbol or have a `name` that is an identifier or string literal
407
- var name_1 = (symbol_4 === null || symbol_4 === void 0 ? void 0 : symbol_4.name) ||
408
+ const name = (symbol === null || symbol === void 0 ? void 0 : symbol.name) ||
408
409
  (t.isIdentifier(node.name)
409
410
  ? node.name.text
410
411
  : t.isStringLiteral(node.name)
411
412
  ? node.name.text
412
413
  : '');
413
- return __assign({ kind: 'property', name: name_1, required: node.questionToken ? false : true, type: node.type
414
+ return {
415
+ kind: 'property',
416
+ name,
417
+ required: node.questionToken ? false : true,
418
+ type: node.type
414
419
  ? getValueFromNode(parser, node.type)
415
- : unknownValue(safeGetText(checker, node)) }, jsDoc);
420
+ : unknownValue(safeGetText(checker, node)),
421
+ ...jsDoc,
422
+ };
416
423
  }
417
424
  /**
418
425
  * A PropertyDeclaration is a property declared in a class
@@ -426,11 +433,16 @@ function _getValueFromNode(parser, node) {
426
433
  * In this example, the PropertyDeclaration is `a = 'b'`
427
434
  */
428
435
  if (t.isPropertyDeclaration(node)) {
429
- var name_2 = getNodeName(node);
430
- var symbol_5 = getSymbolFromNode(checker, node);
431
- var jsDoc = findDocComment(checker, symbol_5);
432
- var type = checker.getTypeAtLocation(node);
433
- return __assign({ kind: 'property', name: name_2 || (symbol_5 === null || symbol_5 === void 0 ? void 0 : symbol_5.name) || 'unknown', type: getValueFromType(parser, type) || unknownValue(safeGetText(checker, node)) }, jsDoc);
436
+ const name = getNodeName(node);
437
+ const symbol = getSymbolFromNode(checker, node);
438
+ const jsDoc = findDocComment(checker, symbol);
439
+ const type = checker.getTypeAtLocation(node);
440
+ return {
441
+ kind: 'property',
442
+ name: name || (symbol === null || symbol === void 0 ? void 0 : symbol.name) || 'unknown',
443
+ type: getValueFromType(parser, type) || unknownValue(safeGetText(checker, node)),
444
+ ...jsDoc,
445
+ };
434
446
  }
435
447
  /**
436
448
  * An ObjectLiteralExpression is a JS value of an object literal.
@@ -448,8 +460,8 @@ function _getValueFromNode(parser, node) {
448
460
  return {
449
461
  kind: 'object',
450
462
  properties: node.properties
451
- .flatMap(function (property) {
452
- var value = getValueFromNode(parser, property);
463
+ .flatMap(property => {
464
+ const value = getValueFromNode(parser, property);
453
465
  if (value.kind === 'object') {
454
466
  return value.properties;
455
467
  }
@@ -465,35 +477,35 @@ function _getValueFromNode(parser, node) {
465
477
  };
466
478
  }
467
479
  if (t.isSpreadAssignment(node)) {
468
- var symbol_6 = getSymbolFromNode(checker, node.expression);
469
- var declaration = getValueDeclaration(symbol_6);
480
+ const symbol = getSymbolFromNode(checker, node.expression);
481
+ const declaration = getValueDeclaration(symbol);
470
482
  if (declaration) {
471
483
  return getValueFromNode(parser, declaration);
472
484
  }
473
485
  }
474
486
  if (t.isArrayLiteralExpression(node)) {
475
- var values_1 = [];
476
- node.elements.forEach(function (element) {
487
+ let values = [];
488
+ node.elements.forEach(element => {
477
489
  if (t.isSpreadElement(element)) {
478
490
  t.getKindNameFromNode(element);
479
- var value = getValueFromNode(parser, element);
491
+ const value = getValueFromNode(parser, element);
480
492
  if (value.kind === 'array' || value.kind === 'tuple') {
481
- values_1 = values_1.concat(value.value);
493
+ values = values.concat(value.value);
482
494
  }
483
495
  }
484
496
  else {
485
- var value = getValueFromNode(parser, element);
486
- values_1.push(value);
497
+ const value = getValueFromNode(parser, element);
498
+ values.push(value);
487
499
  }
488
500
  });
489
501
  return {
490
502
  kind: 'tuple',
491
- value: values_1,
503
+ value: values,
492
504
  };
493
505
  }
494
506
  if (t.isSpreadElement(node)) {
495
- var symbol_7 = getSymbolFromNode(checker, node.expression);
496
- var declaration = getValueDeclaration(symbol_7);
507
+ const symbol = getSymbolFromNode(checker, node.expression);
508
+ const declaration = getValueDeclaration(symbol);
497
509
  if (declaration) {
498
510
  return getValueFromNode(parser, declaration);
499
511
  }
@@ -510,20 +522,27 @@ function _getValueFromNode(parser, node) {
510
522
  *
511
523
  * */
512
524
  if (t.isPropertyAssignment(node)) {
513
- var type = checker.getTypeAtLocation(node);
514
- var symbol_8 = getSymbolFromNode(checker, node);
515
- var jsDoc = findDocComment(checker, symbol_8);
525
+ const type = checker.getTypeAtLocation(node);
526
+ const symbol = getSymbolFromNode(checker, node);
527
+ const jsDoc = findDocComment(checker, symbol);
516
528
  // For default values, we want the value and not the type. An `AsExpression` redirects to types,
517
529
  // so we want to bypass it to get the value node
518
- var defaultValueNode = t.isAsExpression(node.initializer)
530
+ const defaultValueNode = t.isAsExpression(node.initializer)
519
531
  ? node.initializer.expression
520
532
  : node.initializer;
521
- return __assign({ kind: 'property', name: (symbol_8 === null || symbol_8 === void 0 ? void 0 : symbol_8.name) || '', defaultValue: getValueFromNode(parser, defaultValueNode), type: getValueFromType(parser, type) || unknownValue(safeGetText(checker, node)), required: symbol_8 ? !isOptional(symbol_8) && !includesUndefined(type) : false }, jsDoc);
533
+ return {
534
+ kind: 'property',
535
+ name: (symbol === null || symbol === void 0 ? void 0 : symbol.name) || '',
536
+ defaultValue: getValueFromNode(parser, defaultValueNode),
537
+ type: getValueFromType(parser, type) || unknownValue(safeGetText(checker, node)),
538
+ required: symbol ? !isOptional(symbol) && !includesUndefined(type) : false,
539
+ ...jsDoc,
540
+ };
522
541
  }
523
542
  // as A
524
543
  if (t.isAsExpression(node)) {
525
544
  if (safeGetText(checker, node) === 'const') {
526
- var type = checker.getTypeAtLocation(node.parent);
545
+ const type = checker.getTypeAtLocation(node.parent);
527
546
  return getValueFromType(parser, type) || unknownValue(safeGetText(checker, node));
528
547
  }
529
548
  return getValueFromNode(parser, node.type);
@@ -533,16 +552,16 @@ function _getValueFromNode(parser, node) {
533
552
  // something like `keyof A`. In this case, we'll get the symbol and ask for the properties of
534
553
  // the symbol's declaration.
535
554
  if (t.isTypeReference(node.type)) {
536
- var symbol_9 = getSymbolFromNode(checker, node.type.typeName);
537
- var declaration = getValueDeclaration(symbol_9);
538
- if (symbol_9 && declaration && isExportedSymbol(checker, declaration)) {
555
+ const symbol = getSymbolFromNode(checker, node.type.typeName);
556
+ const declaration = getValueDeclaration(symbol);
557
+ if (symbol && declaration && isExportedSymbol(checker, declaration)) {
539
558
  return {
540
559
  kind: 'keyof',
541
560
  name: {
542
561
  kind: 'symbol',
543
- name: symbol_9.name,
562
+ name: symbol.name,
544
563
  fileName: declaration.getSourceFile().fileName,
545
- value: "keyof " + symbol_9.name,
564
+ value: `keyof ${symbol.name}`,
546
565
  },
547
566
  };
548
567
  }
@@ -620,21 +639,21 @@ function _getValueFromNode(parser, node) {
620
639
  }
621
640
  // type A = `{anything}`
622
641
  if (t.isTemplateLiteralType(node)) {
623
- var type = checker.getTypeAtLocation(node);
642
+ const type = checker.getTypeAtLocation(node);
624
643
  return getValueFromType(parser, type, node) || unknownValue(checker.typeToString(type));
625
644
  }
626
645
  // A | B
627
646
  if (t.isUnionType(node)) {
628
647
  return {
629
648
  kind: 'union',
630
- value: node.types.map(function (type) { return getValueFromNode(parser, type); }),
649
+ value: node.types.map(type => getValueFromNode(parser, type)),
631
650
  };
632
651
  }
633
652
  // A & B
634
653
  if (t.isIntersectionType(node)) {
635
654
  return {
636
655
  kind: 'intersection',
637
- value: node.types.map(function (type) { return getValueFromNode(parser, type); }),
656
+ value: node.types.map(type => getValueFromNode(parser, type)),
638
657
  };
639
658
  }
640
659
  // ()
@@ -643,7 +662,7 @@ function _getValueFromNode(parser, node) {
643
662
  }
644
663
  // type A = B['C']
645
664
  if (t.isIndexedAccessType(node)) {
646
- var type = checker.getTypeAtLocation(node);
665
+ const type = checker.getTypeAtLocation(node);
647
666
  return getValueFromType(parser, type, node) || unknownValue(safeGetText(checker, node));
648
667
  }
649
668
  /**
@@ -684,15 +703,15 @@ function _getValueFromNode(parser, node) {
684
703
  */
685
704
  if (t.isQualifiedName(node)) {
686
705
  if (isExportedSymbol(checker, node.left)) {
687
- var value = checker.typeToString(checker.getTypeAtLocation(node.left));
706
+ const value = checker.typeToString(checker.getTypeAtLocation(node.left));
688
707
  return {
689
708
  kind: 'qualifiedName',
690
- left: { kind: 'symbol', name: safeGetText(checker, node.left), value: value },
709
+ left: { kind: 'symbol', name: safeGetText(checker, node.left), value },
691
710
  right: { kind: 'string', value: safeGetText(checker, node.right) },
692
711
  };
693
712
  }
694
713
  // if the node.left is not exported, we'll reduce to a type
695
- var type = checker.getTypeAtLocation(node);
714
+ const type = checker.getTypeAtLocation(node);
696
715
  return getValueFromType(parser, type, node) || unknownValue(checker.typeToString(type));
697
716
  }
698
717
  /**
@@ -707,12 +726,12 @@ function _getValueFromNode(parser, node) {
707
726
  */
708
727
  if (t.isTypeQuery(node)) {
709
728
  if (isExportedSymbol(checker, node.exprName)) {
710
- var value = checker.typeToString(checker.getTypeAtLocation(node.exprName));
711
- return { kind: 'symbol', name: node.exprName.getText(), value: value };
729
+ const value = checker.typeToString(checker.getTypeAtLocation(node.exprName));
730
+ return { kind: 'symbol', name: node.exprName.getText(), value };
712
731
  }
713
- var symbol_10 = getSymbolFromNode(checker, node.exprName);
714
- if (symbol_10) {
715
- var declaration = getValueDeclaration(symbol_10);
732
+ const symbol = getSymbolFromNode(checker, node.exprName);
733
+ if (symbol) {
734
+ const declaration = getValueDeclaration(symbol);
716
735
  return getValueFromNode(parser, declaration);
717
736
  }
718
737
  }
@@ -728,11 +747,11 @@ function _getValueFromNode(parser, node) {
728
747
  * add additional properties on the function.
729
748
  */
730
749
  if (t.isPropertyAccessExpression(node)) {
731
- var typeInfo = void 0;
750
+ let typeInfo;
732
751
  if (t.isAsExpression(node.name)) {
733
752
  typeInfo = getValueFromNode(parser, node.name);
734
753
  }
735
- var type = checker.getTypeAtLocation(node);
754
+ const type = checker.getTypeAtLocation(node);
736
755
  typeInfo = getValueFromType(parser, type) || unknownValue(checker.typeToString(type));
737
756
  return { kind: 'property', name: node.name.getText(), type: typeInfo };
738
757
  }
@@ -753,25 +772,25 @@ function _getValueFromNode(parser, node) {
753
772
  if (t.isTypeReference(node)) {
754
773
  // handle `as const` specially. If we don't do this, we'll get into an infinite loop
755
774
  if (safeGetText(checker, node) === 'const') {
756
- var type_1 = checker.getTypeAtLocation(node.parent.parent);
757
- return getValueFromType(parser, type_1) || unknownValue(node.parent.parent.getText());
775
+ const type = checker.getTypeAtLocation(node.parent.parent);
776
+ return getValueFromType(parser, type) || unknownValue(node.parent.parent.getText());
758
777
  }
759
- var typeParameters = (_e = node.typeArguments) === null || _e === void 0 ? void 0 : _e.map(function (p) { return getValueFromNode(parser, p); });
760
- var symbolNode = t.isQualifiedName(node.typeName) ? node.typeName.right : node.typeName;
761
- var symbol_11 = getSymbolFromNode(checker, symbolNode);
762
- var fileName = (_f = getValueDeclaration(symbol_11)) === null || _f === void 0 ? void 0 : _f.getSourceFile().fileName;
763
- var externalSymbol = getExternalSymbol((symbol_11 === null || symbol_11 === void 0 ? void 0 : symbol_11.name) || safeGetText(checker, node), fileName);
778
+ const typeParameters = (_e = node.typeArguments) === null || _e === void 0 ? void 0 : _e.map(p => getValueFromNode(parser, p));
779
+ const symbolNode = t.isQualifiedName(node.typeName) ? node.typeName.right : node.typeName;
780
+ const symbol = getSymbolFromNode(checker, symbolNode);
781
+ const fileName = (_f = getValueDeclaration(symbol)) === null || _f === void 0 ? void 0 : _f.getSourceFile().fileName;
782
+ const externalSymbol = getExternalSymbol((symbol === null || symbol === void 0 ? void 0 : symbol.name) || safeGetText(checker, node), fileName);
764
783
  if (externalSymbol) {
765
784
  return {
766
785
  kind: 'external',
767
- name: (symbol_11 === null || symbol_11 === void 0 ? void 0 : symbol_11.name) || '',
786
+ name: (symbol === null || symbol === void 0 ? void 0 : symbol.name) || '',
768
787
  url: externalSymbol,
769
- typeParameters: typeParameters,
788
+ typeParameters,
770
789
  };
771
790
  }
772
791
  if (isExportedSymbol(checker, symbolNode)) {
773
- var value = checker.typeToString(checker.getTypeAtLocation(node.typeName));
774
- return { kind: 'symbol', name: safeGetText(checker, node.typeName), typeParameters: typeParameters, value: value };
792
+ const value = checker.typeToString(checker.getTypeAtLocation(node.typeName));
793
+ return { kind: 'symbol', name: safeGetText(checker, node.typeName), typeParameters, value };
775
794
  }
776
795
  // If it is a qualified name, handle that specially. The `left` might be a symbol
777
796
  if (t.isQualifiedName(node.typeName)) {
@@ -779,15 +798,15 @@ function _getValueFromNode(parser, node) {
779
798
  }
780
799
  // The TypeReference isn't exported, so we'll return the type of the
781
800
  // symbol's value declaration directly
782
- var type = checker.getTypeAtLocation(node);
783
- if (symbol_11) {
801
+ const type = checker.getTypeAtLocation(node);
802
+ if (symbol) {
784
803
  if (type.getFlags() & ts.TypeFlags.Instantiable) {
785
804
  // It is a generic type
786
- return { kind: 'generic', name: symbol_11 === null || symbol_11 === void 0 ? void 0 : symbol_11.name };
805
+ return { kind: 'generic', name: symbol === null || symbol === void 0 ? void 0 : symbol.name };
787
806
  }
788
- var declaration = getValueDeclaration(symbol_11);
807
+ const declaration = getValueDeclaration(symbol);
789
808
  if (declaration) {
790
- var typeInfo = getValueFromNode(parser, declaration);
809
+ const typeInfo = getValueFromNode(parser, declaration);
791
810
  // we want to embed objects
792
811
  if (typeInfo.kind === 'object') {
793
812
  return typeInfo;
@@ -818,11 +837,16 @@ function _getValueFromNode(parser, node) {
818
837
  * points to the VariableDeclaration.
819
838
  */
820
839
  if (t.isShorthandPropertyAssignment(node)) {
821
- var type = checker.getTypeAtLocation(node);
822
- var symbol_12 = getSymbolFromNode(checker, node);
823
- var jsDoc = findDocComment(checker, symbol_12);
840
+ const type = checker.getTypeAtLocation(node);
841
+ const symbol = getSymbolFromNode(checker, node);
842
+ const jsDoc = findDocComment(checker, symbol);
824
843
  // see if the declaration is assigned to something exported
825
- return __assign({ kind: 'property', name: (symbol_12 === null || symbol_12 === void 0 ? void 0 : symbol_12.name) || '', type: getValueFromType(parser, type) || unknownValue(safeGetText(checker, node)) }, jsDoc);
844
+ return {
845
+ kind: 'property',
846
+ name: (symbol === null || symbol === void 0 ? void 0 : symbol.name) || '',
847
+ type: getValueFromType(parser, type) || unknownValue(safeGetText(checker, node)),
848
+ ...jsDoc,
849
+ };
826
850
  }
827
851
  /**
828
852
  * Declaration of a enum
@@ -839,7 +863,7 @@ function _getValueFromNode(parser, node) {
839
863
  return {
840
864
  kind: 'object',
841
865
  typeParameters: [],
842
- properties: node.members.map(function (m, index) {
866
+ properties: node.members.map((m, index) => {
843
867
  return {
844
868
  kind: 'property',
845
869
  name: safeGetText(checker, m.name),
@@ -865,8 +889,8 @@ function _getValueFromNode(parser, node) {
865
889
  */
866
890
  if (t.isIdentifier(node)) {
867
891
  if (isExportedSymbol(checker, node)) {
868
- var symbol_13 = getSymbolFromNode(checker, node);
869
- var declaration = getValueDeclaration(symbol_13);
892
+ const symbol = getSymbolFromNode(checker, node);
893
+ const declaration = getValueDeclaration(symbol);
870
894
  return {
871
895
  kind: 'symbol',
872
896
  name: node.text,
@@ -882,20 +906,20 @@ function _getValueFromNode(parser, node) {
882
906
  *
883
907
  */
884
908
  if (t.isParameter(node)) {
885
- var type = checker.getTypeAtLocation(node);
886
- var symbol_14 = getSymbolFromNode(checker, node);
887
- var jsDoc = findDocComment(checker, symbol_14);
888
- var isRequired = node.questionToken
909
+ const type = checker.getTypeAtLocation(node);
910
+ const symbol = getSymbolFromNode(checker, node);
911
+ const jsDoc = findDocComment(checker, symbol);
912
+ const isRequired = node.questionToken
889
913
  ? false
890
914
  : node.initializer
891
915
  ? false
892
- : symbol_14
893
- ? !isOptional(symbol_14) && !includesUndefined(type)
916
+ : symbol
917
+ ? !isOptional(symbol) && !includesUndefined(type)
894
918
  : false;
895
- var typeInfo = node.type
919
+ const typeInfo = node.type
896
920
  ? getValueFromNode(parser, node.type)
897
921
  : getValueFromType(parser, type) || unknownValue(safeGetText(checker, node));
898
- var defaultValue = node.initializer ? getValueFromNode(parser, node.initializer) : undefined;
922
+ const defaultValue = node.initializer ? getValueFromNode(parser, node.initializer) : undefined;
899
923
  /**
900
924
  * Set default values if an object binding pattern is found. We do this at the Parameter level,
901
925
  * because we have all the info here.
@@ -908,29 +932,37 @@ function _getValueFromNode(parser, node) {
908
932
  * In this example, the ObjectBindingPattern is `{ a = 'a', b }`
909
933
  */
910
934
  if (t.isObjectBindingPattern(node.name)) {
911
- var defaults_1 = getDefaultsFromObjectBindingParameter(parser, node);
935
+ const defaults = getDefaultsFromObjectBindingParameter(parser, node);
912
936
  if (typeInfo.kind === 'object') {
913
- typeInfo.properties.forEach(function (p) {
914
- if (!p.defaultValue && defaults_1[p.name]) {
915
- p.defaultValue = defaults_1[p.name];
937
+ typeInfo.properties.forEach(p => {
938
+ if (!p.defaultValue && defaults[p.name]) {
939
+ p.defaultValue = defaults[p.name];
916
940
  }
917
941
  });
918
942
  }
919
943
  }
920
- return __assign({ kind: 'parameter', name: (symbol_14 === null || symbol_14 === void 0 ? void 0 : symbol_14.name) || '', defaultValue: defaultValue, type: typeInfo, required: isRequired, rest: !!node.dotDotDotToken }, jsDoc);
944
+ return {
945
+ kind: 'parameter',
946
+ name: (symbol === null || symbol === void 0 ? void 0 : symbol.name) || '',
947
+ defaultValue,
948
+ type: typeInfo,
949
+ required: isRequired,
950
+ rest: !!node.dotDotDotToken,
951
+ ...jsDoc,
952
+ };
921
953
  }
922
954
  /**
923
955
  * A call expression is an expression calling a function. In this case, we want to get the signature
924
956
  * and get a type for the return type
925
957
  */
926
958
  if (t.isCallExpression(node)) {
927
- var type = checker.getTypeAtLocation(node);
928
- var value = getValueFromType(parser, type);
959
+ const type = checker.getTypeAtLocation(node);
960
+ const value = getValueFromType(parser, type);
929
961
  if (value) {
930
962
  return value;
931
963
  }
932
964
  }
933
- var symbol = getSymbolFromNode(checker, node);
965
+ const symbol = getSymbolFromNode(checker, node);
934
966
  if (!symbol) {
935
967
  return unknownValue(safeGetText(checker, node));
936
968
  }
@@ -940,7 +972,7 @@ function _getValueFromNode(parser, node) {
940
972
  function isNodeExported(checker, node) {
941
973
  return (ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export) !== 0;
942
974
  }
943
- export var defaultJSDoc = {
975
+ export const defaultJSDoc = {
944
976
  description: '',
945
977
  tags: {},
946
978
  declarations: [],
@@ -950,37 +982,37 @@ export function getFullJsDocComment(checker, symbol) {
950
982
  if (symbol.getDocumentationComment === undefined) {
951
983
  return defaultJSDoc;
952
984
  }
953
- var mainComment = ts.displayPartsToString(symbol.getDocumentationComment(checker));
985
+ let mainComment = ts.displayPartsToString(symbol.getDocumentationComment(checker));
954
986
  if (mainComment) {
955
987
  mainComment = mainComment.replace(/\r\n/g, '\n');
956
988
  }
957
- var tags = symbol.getJsDocTags() || [];
958
- var tagMap = {};
959
- tags.forEach(function (tag) {
960
- var trimmedText = (tag.text || '').trim();
961
- var currentValue = tagMap[tag.name];
989
+ const tags = symbol.getJsDocTags() || [];
990
+ const tagMap = {};
991
+ tags.forEach(tag => {
992
+ const trimmedText = (tag.text || '').trim();
993
+ const currentValue = tagMap[tag.name];
962
994
  tagMap[tag.name] = currentValue ? currentValue + '\n' + trimmedText : trimmedText;
963
995
  });
964
996
  return {
965
997
  description: mainComment,
966
- declarations: ((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) !== null && _a !== void 0 ? _a : []).map(function (d) { return ({
998
+ declarations: ((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) !== null && _a !== void 0 ? _a : []).map(d => ({
967
999
  name: (symbol === null || symbol === void 0 ? void 0 : symbol.name) || '',
968
1000
  filePath: d.getSourceFile().fileName,
969
- }); }),
1001
+ })),
970
1002
  tags: tagMap,
971
1003
  };
972
1004
  }
973
1005
  export function findDocComment(checker, symbol) {
974
1006
  if (symbol) {
975
- var comment_1 = getFullJsDocComment(checker, symbol);
976
- if (comment_1.description || comment_1.declarations.length || comment_1.tags.default) {
977
- return comment_1;
1007
+ const comment = getFullJsDocComment(checker, symbol);
1008
+ if (comment.description || comment.declarations.length || comment.tags.default) {
1009
+ return comment;
978
1010
  }
979
- var rootSymbols = checker.getRootSymbols(symbol);
980
- var commentsOnRootSymbols = rootSymbols
981
- .filter(function (x) { return x !== symbol; })
982
- .map(function (x) { return getFullJsDocComment(checker, x); })
983
- .filter(function (x) { return !!x.description || !!comment_1.tags.default; });
1011
+ const rootSymbols = checker.getRootSymbols(symbol);
1012
+ const commentsOnRootSymbols = rootSymbols
1013
+ .filter(x => x !== symbol)
1014
+ .map(x => getFullJsDocComment(checker, x))
1015
+ .filter(x => !!x.description || !!comment.tags.default);
984
1016
  if (commentsOnRootSymbols.length) {
985
1017
  return commentsOnRootSymbols[0];
986
1018
  }
@@ -991,7 +1023,7 @@ export function findDocComment(checker, symbol) {
991
1023
  * Attempt to get the name of a declaration or expression
992
1024
  */
993
1025
  export function getNodeName(node) {
994
- var name = ts.getNameOfDeclaration(node);
1026
+ const name = ts.getNameOfDeclaration(node);
995
1027
  if (name && 'text' in name) {
996
1028
  return name.text;
997
1029
  }
@@ -1014,7 +1046,7 @@ export function isObject(type) {
1014
1046
  return !!(type.flags & ts.TypeFlags.Object);
1015
1047
  }
1016
1048
  function includesUndefined(type) {
1017
- return type.isUnion() ? type.types.some(function (t) { return t.flags & ts.TypeFlags.Undefined; }) : false;
1049
+ return type.isUnion() ? type.types.some(t => t.flags & ts.TypeFlags.Undefined) : false;
1018
1050
  }
1019
1051
  function isTupleType(type) {
1020
1052
  var _a;
@@ -1051,9 +1083,9 @@ export function getValidDefaultFromNode(parser, node) {
1051
1083
  */
1052
1084
  export function getDefaultsFromObjectBindingParameter(parser, node) {
1053
1085
  if (t.isObjectBindingPattern(node.name)) {
1054
- return node.name.elements.reduce(function (result, element) {
1086
+ return node.name.elements.reduce((result, element) => {
1055
1087
  if (t.isBindingElement(element) && t.isIdentifier(element.name) && element.initializer) {
1056
- var defaultValue = getValidDefaultFromNode(parser, element.initializer);
1088
+ const defaultValue = getValidDefaultFromNode(parser, element.initializer);
1057
1089
  if (defaultValue) {
1058
1090
  result[element.name.text] = defaultValue;
1059
1091
  }
@@ -1081,11 +1113,11 @@ export function getDefaultsFromObjectBindingParameter(parser, node) {
1081
1113
  */
1082
1114
  function getIndexSignatureFromType(parser, type) {
1083
1115
  var _a;
1084
- var checker = parser.checker;
1085
- var indexSignature = checker.getIndexInfoOfType(type, ts.IndexKind.String) ||
1116
+ const { checker } = parser;
1117
+ const indexSignature = checker.getIndexInfoOfType(type, ts.IndexKind.String) ||
1086
1118
  checker.getIndexInfoOfType(type, ts.IndexKind.Number);
1087
1119
  if (indexSignature) {
1088
- var parameter = (_a = indexSignature.declaration) === null || _a === void 0 ? void 0 : _a.parameters[0];
1120
+ const parameter = (_a = indexSignature.declaration) === null || _a === void 0 ? void 0 : _a.parameters[0];
1089
1121
  return {
1090
1122
  kind: 'indexSignature',
1091
1123
  name: (parameter === null || parameter === void 0 ? void 0 : parameter.name) ? safeGetText(checker, parameter === null || parameter === void 0 ? void 0 : parameter.name) : '',
@@ -1107,23 +1139,23 @@ function getIndexSignatureFromType(parser, type) {
1107
1139
  * infinite loops.
1108
1140
  */
1109
1141
  export function getValueFromType(parser, type, node) {
1110
- var checker = parser.checker;
1111
- var originalNodeKind = node === null || node === void 0 ? void 0 : node.kind;
1112
- var typeToString = checker.typeToString(type);
1142
+ const { checker } = parser;
1143
+ const originalNodeKind = node === null || node === void 0 ? void 0 : node.kind;
1144
+ const typeToString = checker.typeToString(type);
1113
1145
  // If the type is `any`, we want to bail now
1114
1146
  if (type.flags & ts.TypeFlags.Any) {
1115
1147
  return { kind: 'primitive', value: 'any' };
1116
1148
  }
1117
1149
  // check if the node is an external symbol
1118
1150
  // TODO: This won't work if the symbol contains a generic
1119
- var externalSymbol = getExternalSymbol(typeToString);
1151
+ const externalSymbol = getExternalSymbol(typeToString);
1120
1152
  if (externalSymbol) {
1121
1153
  return { kind: 'external', name: typeToString, url: externalSymbol };
1122
1154
  }
1123
1155
  if (isTupleType(type)) {
1124
1156
  return {
1125
1157
  kind: 'union',
1126
- value: checker.getTypeArguments(type).map(function (t) { return getValueFromType(parser, t) || unknownValue(''); }) ||
1158
+ value: checker.getTypeArguments(type).map(t => getValueFromType(parser, t) || unknownValue('')) ||
1127
1159
  [],
1128
1160
  };
1129
1161
  }
@@ -1150,20 +1182,20 @@ export function getValueFromType(parser, type, node) {
1150
1182
  // service uses for the tooltips when hovering over text in your IDE. We try to go from Type to
1151
1183
  // Node whenever possible, but there are some cases where interacting directly with the types is
1152
1184
  // preferred. The union example is one of such examples.
1153
- var typeNode = checker.typeToTypeNode(type, node, ts.NodeBuilderFlags.NoTruncation);
1185
+ const typeNode = checker.typeToTypeNode(type, node, ts.NodeBuilderFlags.NoTruncation);
1154
1186
  // We try to extract useful type information from the TypeNode and go back to recursing the AST.
1155
1187
  // But, if the typeNode and original node have the same kind, we've actually lost information and
1156
1188
  // should skip processing the TypeNode.
1157
1189
  if (typeNode && originalNodeKind !== typeNode.kind) {
1158
1190
  // find the symbol
1159
1191
  if (t.isTypeReference(typeNode)) {
1160
- var symbol = getSymbolFromNode(checker, typeNode.typeName);
1161
- var declaration = getValueDeclaration(symbol);
1162
- var fileName = declaration === null || declaration === void 0 ? void 0 : declaration.getSourceFile().fileName;
1192
+ const symbol = getSymbolFromNode(checker, typeNode.typeName);
1193
+ const declaration = getValueDeclaration(symbol);
1194
+ const fileName = declaration === null || declaration === void 0 ? void 0 : declaration.getSourceFile().fileName;
1163
1195
  if (symbol) {
1164
- var externalSymbol_1 = getExternalSymbol(symbol.name, fileName);
1165
- if (externalSymbol_1) {
1166
- return { kind: 'external', name: symbol.name, url: externalSymbol_1 };
1196
+ const externalSymbol = getExternalSymbol(symbol.name, fileName);
1197
+ if (externalSymbol) {
1198
+ return { kind: 'external', name: symbol.name, url: externalSymbol };
1167
1199
  }
1168
1200
  if (declaration && declaration !== node) {
1169
1201
  if (isExportedSymbol(checker, declaration)) {
@@ -1176,18 +1208,16 @@ export function getValueFromType(parser, type, node) {
1176
1208
  // Figure out if we should recurse back into AST nodes with our synthetic TypeNode. There are
1177
1209
  // exceptions to using the TypeNode. Exceptions where we actually lose type information. Some
1178
1210
  // examples are large unions or `keyof`:
1179
- var exceptions = false;
1211
+ let exceptions = false;
1180
1212
  // The typeNode is a UnionType, but the number of items has overflowed with an identifier `...
1181
1213
  // {N} more ...`, so we don't want to use the typeNode and will use `type.types` instead which
1182
1214
  // is not shortened. In this case we want to do nothing and use the type-based union check
1183
1215
  if (t.isUnionType(typeNode) &&
1184
1216
  type.isUnion() &&
1185
- typeNode.types.some(function (v) {
1186
- return t.isIdentifier(v) ||
1187
- (t.isTypeReference(v) &&
1188
- t.isIdentifier(v.typeName) &&
1189
- v.typeName.escapedText.includes('more'));
1190
- })) {
1217
+ typeNode.types.some(v => t.isIdentifier(v) ||
1218
+ (t.isTypeReference(v) &&
1219
+ t.isIdentifier(v.typeName) &&
1220
+ v.typeName.escapedText.includes('more')))) {
1191
1221
  exceptions = true;
1192
1222
  }
1193
1223
  // A function TypeNode looses a lot of information. We'll fallback to using the type. A Function
@@ -1230,10 +1260,10 @@ export function getValueFromType(parser, type, node) {
1230
1260
  if (type.isUnion()) {
1231
1261
  // If we got here, it means a TypeNode was a TypeReference that wasn't exported or a synthetic
1232
1262
  // TypeNode `keyof *` that `getValueFromNode` couldn't properly parse.
1233
- var filteredTypes = type.types;
1263
+ let filteredTypes = type.types;
1234
1264
  return {
1235
1265
  kind: 'union',
1236
- value: filteredTypes.map(function (t) { return getValueFromType(parser, t) || unknownValue(checker.typeToString(t)); }),
1266
+ value: filteredTypes.map(t => getValueFromType(parser, t) || unknownValue(checker.typeToString(t))),
1237
1267
  };
1238
1268
  }
1239
1269
  if (type.isStringLiteral()) {
@@ -1268,9 +1298,9 @@ export function getValueFromType(parser, type, node) {
1268
1298
  }
1269
1299
  if (isObject(type)) {
1270
1300
  if (type.objectFlags & ts.ObjectFlags.ArrayLiteral) {
1271
- var typeNode_1 = checker.typeToTypeNode(type, undefined, undefined);
1272
- if (typeNode_1) {
1273
- return getValueFromNode(parser, typeNode_1);
1301
+ const typeNode = checker.typeToTypeNode(type, undefined, undefined);
1302
+ if (typeNode) {
1303
+ return getValueFromNode(parser, typeNode);
1274
1304
  }
1275
1305
  }
1276
1306
  return getObjectValueFromType(parser, type);
@@ -1282,12 +1312,12 @@ export function unknownValue(nodeText) {
1282
1312
  }
1283
1313
  export function isExportedSymbol(checker, node) {
1284
1314
  var _a;
1285
- var sourceFile = (_a = node.getSourceFile) === null || _a === void 0 ? void 0 : _a.call(node);
1315
+ const sourceFile = (_a = node.getSourceFile) === null || _a === void 0 ? void 0 : _a.call(node);
1286
1316
  if (sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.isDeclarationFile) {
1287
1317
  return true;
1288
1318
  }
1289
- var symbol = getSymbolFromNode(checker, node);
1290
- var declarationNode = getValueDeclaration(symbol);
1319
+ const symbol = getSymbolFromNode(checker, node);
1320
+ const declarationNode = getValueDeclaration(symbol);
1291
1321
  if (declarationNode) {
1292
1322
  t.getKindNameFromNode(declarationNode);
1293
1323
  // Check if the declaration's sourcefile is a declaration file
@@ -1322,8 +1352,8 @@ function safeGetText(checker, node) {
1322
1352
  return node.text;
1323
1353
  }
1324
1354
  // Try a symbol
1325
- var symbol = getSymbolFromNode(checker, node);
1326
- return (symbol === null || symbol === void 0 ? void 0 : symbol.name) || "SyntheticNode - " + t.getKindNameFromNode(node);
1355
+ const symbol = getSymbolFromNode(checker, node);
1356
+ return (symbol === null || symbol === void 0 ? void 0 : symbol.name) || `SyntheticNode - ${t.getKindNameFromNode(node)}`;
1327
1357
  }
1328
1358
  /**
1329
1359
  * Get export members of a node. Export members are additional members of a declaration.
@@ -1337,64 +1367,64 @@ function safeGetText(checker, node) {
1337
1367
  */
1338
1368
  function getExportMembers(parser, node) {
1339
1369
  var _a;
1340
- var checker = parser.checker;
1341
- var exports = ((_a = getSymbolFromNode(checker, node)) === null || _a === void 0 ? void 0 : _a.exports) || new Map();
1342
- var members = Array.from(exports.values())
1343
- .map(function (symbol) {
1344
- var declaration = getValueDeclaration(symbol);
1370
+ const { checker } = parser;
1371
+ const exports = ((_a = getSymbolFromNode(checker, node)) === null || _a === void 0 ? void 0 : _a.exports) || new Map();
1372
+ const members = Array.from(exports.values())
1373
+ .map(symbol => {
1374
+ const declaration = getValueDeclaration(symbol);
1345
1375
  if (declaration) {
1346
1376
  return getValueFromNode(parser, declaration);
1347
1377
  }
1348
1378
  return;
1349
1379
  })
1350
- .filter(function (i) { return !!i; });
1380
+ .filter((i) => !!i);
1351
1381
  return members;
1352
1382
  }
1353
1383
  function getValueFromSignature(parser, declaration, signature) {
1354
1384
  var _a;
1355
- var members = getExportMembers(parser, declaration);
1356
- var typeParameters = (_a = signature.typeParameters) === null || _a === void 0 ? void 0 : _a.map(function (p) { return getValueFromType(parser, p); }).filter(function (v) { return (v === null || v === void 0 ? void 0 : v.kind) === 'typeParameter'; });
1357
- var parameters = signature.parameters.map(function (s) {
1385
+ const members = getExportMembers(parser, declaration);
1386
+ const typeParameters = (_a = signature.typeParameters) === null || _a === void 0 ? void 0 : _a.map(p => getValueFromType(parser, p)).filter((v) => (v === null || v === void 0 ? void 0 : v.kind) === 'typeParameter');
1387
+ const parameters = signature.parameters.map(s => {
1358
1388
  return getValueFromNode(parser, getValueDeclaration(s));
1359
1389
  });
1360
- var returnType = declaration.type
1390
+ const returnType = declaration.type
1361
1391
  ? getValueFromNode(parser, declaration.type)
1362
1392
  : getValueFromType(parser, signature.getReturnType()) || unknownValue(declaration.getText());
1363
1393
  return {
1364
1394
  kind: 'function',
1365
- typeParameters: typeParameters,
1366
- parameters: parameters,
1367
- members: members,
1368
- returnType: returnType,
1395
+ typeParameters,
1396
+ parameters,
1397
+ members,
1398
+ returnType,
1369
1399
  };
1370
1400
  }
1371
1401
  function generateSignatureFromTypeNode(parser, node) {
1372
1402
  var _a;
1373
1403
  if (t.isFunctionType(node) || t.isMethodSignature(node)) {
1374
- var parameters_1 = node.parameters.map(function (p) { return (getSymbolFromNode(parser.checker, p) || getSymbolFromNode(parser.checker, p.name)); });
1375
- var typeParameters_1 = (_a = node.typeParameters) === null || _a === void 0 ? void 0 : _a.map(function (t) { return parser.checker.getTypeAtLocation(t); });
1404
+ const parameters = node.parameters.map(p => (getSymbolFromNode(parser.checker, p) || getSymbolFromNode(parser.checker, p.name)));
1405
+ const typeParameters = (_a = node.typeParameters) === null || _a === void 0 ? void 0 : _a.map(t => parser.checker.getTypeAtLocation(t));
1376
1406
  return {
1377
- parameters: parameters_1,
1407
+ parameters,
1378
1408
  declaration: node,
1379
- typeParameters: typeParameters_1,
1380
- getDeclaration: function () {
1409
+ typeParameters,
1410
+ getDeclaration() {
1381
1411
  return node;
1382
1412
  },
1383
- getParameters: function () {
1384
- return parameters_1;
1413
+ getParameters() {
1414
+ return parameters;
1385
1415
  },
1386
- getTypeParameters: function () {
1387
- return typeParameters_1;
1416
+ getTypeParameters() {
1417
+ return typeParameters;
1388
1418
  },
1389
- getReturnType: function () {
1419
+ getReturnType() {
1390
1420
  return parser.checker.getTypeAtLocation(node.type || node);
1391
1421
  },
1392
- getDocumentationComment: function () {
1393
- var symbol = getSymbolFromNode(parser.checker, node);
1422
+ getDocumentationComment() {
1423
+ const symbol = getSymbolFromNode(parser.checker, node);
1394
1424
  return symbol.getDocumentationComment(parser.checker);
1395
1425
  },
1396
- getJsDocTags: function () {
1397
- var symbol = getSymbolFromNode(parser.checker, node);
1426
+ getJsDocTags() {
1427
+ const symbol = getSymbolFromNode(parser.checker, node);
1398
1428
  return symbol.getJsDocTags();
1399
1429
  },
1400
1430
  };
@@ -1402,8 +1432,8 @@ function generateSignatureFromTypeNode(parser, node) {
1402
1432
  return undefined;
1403
1433
  }
1404
1434
  export function getValueFromSignatureNode(parser, declaration) {
1405
- var checker = parser.checker;
1406
- var signature = checker.getSignatureFromDeclaration(declaration) ||
1435
+ const { checker } = parser;
1436
+ const signature = checker.getSignatureFromDeclaration(declaration) ||
1407
1437
  generateSignatureFromTypeNode(parser, declaration);
1408
1438
  if (signature) {
1409
1439
  return getValueFromSignature(parser, declaration, signature);
@@ -1411,13 +1441,13 @@ export function getValueFromSignatureNode(parser, declaration) {
1411
1441
  return unknownValue(safeGetText(checker, declaration));
1412
1442
  }
1413
1443
  function getObjectValueFromType(parser, type) {
1414
- var properties = type
1444
+ const properties = type
1415
1445
  .getProperties()
1416
- .map(function (symbol) {
1446
+ .map(symbol => {
1417
1447
  return getValueFromNode(parser, getValueDeclaration(symbol));
1418
1448
  })
1419
1449
  .filter(filterObjectProperties);
1420
- var callSignatures = type.getCallSignatures().map(function (s) {
1450
+ const callSignatures = type.getCallSignatures().map(s => {
1421
1451
  return getValueFromSignatureNode(parser, s.getDeclaration());
1422
1452
  });
1423
1453
  if (callSignatures.length) {
@@ -1427,17 +1457,16 @@ function getObjectValueFromType(parser, type) {
1427
1457
  }
1428
1458
  return callSignatures[0];
1429
1459
  }
1430
- return { kind: 'object', properties: properties };
1460
+ return { kind: 'object', properties };
1431
1461
  }
1432
1462
  /**
1433
1463
  * Get defaults from JSDoc tags if available and do some simple processing to extract useful type
1434
1464
  * information. JSDoc tags are not type checked, so our processing is limited.
1435
1465
  */
1436
1466
  export function getDefaultFromTags(tags) {
1437
- for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) {
1438
- var tag = tags_1[_i];
1467
+ for (const tag of tags) {
1439
1468
  if (tag.name === 'default') {
1440
- var text = (tag.text || '').replace('{', '').replace('}', '');
1469
+ const text = (tag.text || '').replace('{', '').replace('}', '');
1441
1470
  if ([
1442
1471
  'string',
1443
1472
  'number',
@@ -1486,8 +1515,7 @@ export function createParserPlugin(fn) {
1486
1515
  * new parser per file. Instead use the parser directly and call `parser.getExportedSymbols` for
1487
1516
  * each file to share memory.
1488
1517
  */
1489
- export function parse(program, fileName, plugins) {
1490
- if (plugins === void 0) { plugins = []; }
1491
- var parser = new DocParser(program, plugins);
1518
+ export function parse(program, fileName, plugins = []) {
1519
+ const parser = new DocParser(program, plugins);
1492
1520
  return parser.getExportedSymbols(fileName);
1493
1521
  }