@teambit/semantics.entities.semantic-schema 0.0.70 → 0.0.71

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 (195) hide show
  1. package/api-schema.ts +49 -1
  2. package/dist/api-schema.d.ts +7 -44
  3. package/dist/api-schema.js +36 -1
  4. package/dist/api-schema.js.map +1 -1
  5. package/dist/{preview-1719137078208.js → preview-1726715976656.js} +1 -1
  6. package/dist/schema-node.d.ts +12 -2
  7. package/dist/schema-node.js.map +1 -1
  8. package/dist/schemas/array-literal-expression.d.ts +3 -0
  9. package/dist/schemas/array-literal-expression.js +4 -0
  10. package/dist/schemas/array-literal-expression.js.map +1 -1
  11. package/dist/schemas/class.d.ts +6 -1
  12. package/dist/schemas/class.js +41 -4
  13. package/dist/schemas/class.js.map +1 -1
  14. package/dist/schemas/conditional-type.d.ts +3 -0
  15. package/dist/schemas/conditional-type.js +7 -0
  16. package/dist/schemas/conditional-type.js.map +1 -1
  17. package/dist/schemas/decorator.d.ts +3 -0
  18. package/dist/schemas/decorator.js +10 -1
  19. package/dist/schemas/decorator.js.map +1 -1
  20. package/dist/schemas/docs/doc.d.ts +1 -0
  21. package/dist/schemas/docs/doc.js +15 -0
  22. package/dist/schemas/docs/doc.js.map +1 -1
  23. package/dist/schemas/docs/property-like-tag.d.ts +3 -0
  24. package/dist/schemas/docs/property-like-tag.js +5 -0
  25. package/dist/schemas/docs/property-like-tag.js.map +1 -1
  26. package/dist/schemas/docs/return-tag.d.ts +3 -0
  27. package/dist/schemas/docs/return-tag.js +5 -0
  28. package/dist/schemas/docs/return-tag.js.map +1 -1
  29. package/dist/schemas/docs/tag.d.ts +1 -0
  30. package/dist/schemas/docs/tag.js +3 -0
  31. package/dist/schemas/docs/tag.js.map +1 -1
  32. package/dist/schemas/enum-member.d.ts +3 -0
  33. package/dist/schemas/enum-member.js +13 -0
  34. package/dist/schemas/enum-member.js.map +1 -1
  35. package/dist/schemas/enum.d.ts +4 -1
  36. package/dist/schemas/enum.js +20 -3
  37. package/dist/schemas/enum.js.map +1 -1
  38. package/dist/schemas/export.d.ts +7 -1
  39. package/dist/schemas/export.js +31 -4
  40. package/dist/schemas/export.js.map +1 -1
  41. package/dist/schemas/expression-with-arguments.d.ts +3 -0
  42. package/dist/schemas/expression-with-arguments.js +8 -0
  43. package/dist/schemas/expression-with-arguments.js.map +1 -1
  44. package/dist/schemas/function-like.d.ts +6 -1
  45. package/dist/schemas/function-like.js +35 -2
  46. package/dist/schemas/function-like.js.map +1 -1
  47. package/dist/schemas/get-accessor.d.ts +6 -1
  48. package/dist/schemas/get-accessor.js +11 -2
  49. package/dist/schemas/get-accessor.js.map +1 -1
  50. package/dist/schemas/ignored.d.ts +1 -0
  51. package/dist/schemas/ignored.js +3 -0
  52. package/dist/schemas/ignored.js.map +1 -1
  53. package/dist/schemas/index-signature.d.ts +3 -0
  54. package/dist/schemas/index-signature.js +5 -0
  55. package/dist/schemas/index-signature.js.map +1 -1
  56. package/dist/schemas/indexed-access-type.d.ts +3 -0
  57. package/dist/schemas/indexed-access-type.js +5 -0
  58. package/dist/schemas/indexed-access-type.js.map +1 -1
  59. package/dist/schemas/inference-type.d.ts +1 -0
  60. package/dist/schemas/inference-type.js +11 -0
  61. package/dist/schemas/inference-type.js.map +1 -1
  62. package/dist/schemas/interface.d.ts +6 -1
  63. package/dist/schemas/interface.js +31 -3
  64. package/dist/schemas/interface.js.map +1 -1
  65. package/dist/schemas/keyword-type.d.ts +1 -0
  66. package/dist/schemas/keyword-type.js +3 -0
  67. package/dist/schemas/keyword-type.js.map +1 -1
  68. package/dist/schemas/literal-type.d.ts +1 -0
  69. package/dist/schemas/literal-type.js +3 -0
  70. package/dist/schemas/literal-type.js.map +1 -1
  71. package/dist/schemas/literal-value.d.ts +1 -0
  72. package/dist/schemas/literal-value.js +3 -0
  73. package/dist/schemas/literal-value.js.map +1 -1
  74. package/dist/schemas/module.d.ts +10 -27
  75. package/dist/schemas/module.js +15 -3
  76. package/dist/schemas/module.js.map +1 -1
  77. package/dist/schemas/named-tuple.d.ts +6 -1
  78. package/dist/schemas/named-tuple.js +5 -2
  79. package/dist/schemas/named-tuple.js.map +1 -1
  80. package/dist/schemas/object-literal-expression.d.ts +6 -1
  81. package/dist/schemas/object-literal-expression.js +9 -2
  82. package/dist/schemas/object-literal-expression.js.map +1 -1
  83. package/dist/schemas/parameter.d.ts +3 -0
  84. package/dist/schemas/parameter.js +31 -0
  85. package/dist/schemas/parameter.js.map +1 -1
  86. package/dist/schemas/parenthesized-type.d.ts +6 -1
  87. package/dist/schemas/parenthesized-type.js +5 -2
  88. package/dist/schemas/parenthesized-type.js.map +1 -1
  89. package/dist/schemas/property-assignment.d.ts +6 -1
  90. package/dist/schemas/property-assignment.js +11 -2
  91. package/dist/schemas/property-assignment.js.map +1 -1
  92. package/dist/schemas/set-accessor.d.ts +3 -0
  93. package/dist/schemas/set-accessor.js +4 -0
  94. package/dist/schemas/set-accessor.js.map +1 -1
  95. package/dist/schemas/template-literal-type-span.d.ts +6 -1
  96. package/dist/schemas/template-literal-type-span.js +5 -2
  97. package/dist/schemas/template-literal-type-span.js.map +1 -1
  98. package/dist/schemas/template-literal-type.d.ts +6 -1
  99. package/dist/schemas/template-literal-type.js +6 -2
  100. package/dist/schemas/template-literal-type.js.map +1 -1
  101. package/dist/schemas/this-type.d.ts +1 -0
  102. package/dist/schemas/this-type.js +3 -0
  103. package/dist/schemas/this-type.js.map +1 -1
  104. package/dist/schemas/tuple-type.d.ts +6 -1
  105. package/dist/schemas/tuple-type.js +5 -2
  106. package/dist/schemas/tuple-type.js.map +1 -1
  107. package/dist/schemas/type-array.d.ts +6 -1
  108. package/dist/schemas/type-array.js +5 -2
  109. package/dist/schemas/type-array.js.map +1 -1
  110. package/dist/schemas/type-intersection.d.ts +6 -1
  111. package/dist/schemas/type-intersection.js +5 -2
  112. package/dist/schemas/type-intersection.js.map +1 -1
  113. package/dist/schemas/type-literal.d.ts +3 -0
  114. package/dist/schemas/type-literal.js +14 -0
  115. package/dist/schemas/type-literal.js.map +1 -1
  116. package/dist/schemas/type-operator.d.ts +6 -1
  117. package/dist/schemas/type-operator.js +5 -2
  118. package/dist/schemas/type-operator.js.map +1 -1
  119. package/dist/schemas/type-predicate.d.ts +6 -1
  120. package/dist/schemas/type-predicate.js +12 -2
  121. package/dist/schemas/type-predicate.js.map +1 -1
  122. package/dist/schemas/type-query.d.ts +6 -1
  123. package/dist/schemas/type-query.js +5 -2
  124. package/dist/schemas/type-query.js.map +1 -1
  125. package/dist/schemas/type-ref.d.ts +6 -1
  126. package/dist/schemas/type-ref.js +19 -6
  127. package/dist/schemas/type-ref.js.map +1 -1
  128. package/dist/schemas/type-union.d.ts +6 -1
  129. package/dist/schemas/type-union.js +11 -2
  130. package/dist/schemas/type-union.js.map +1 -1
  131. package/dist/schemas/type.d.ts +6 -1
  132. package/dist/schemas/type.js +12 -2
  133. package/dist/schemas/type.js.map +1 -1
  134. package/dist/schemas/unimplemented-schema.d.ts +1 -0
  135. package/dist/schemas/unimplemented-schema.js +3 -0
  136. package/dist/schemas/unimplemented-schema.js.map +1 -1
  137. package/dist/schemas/unknown-schema.d.ts +1 -0
  138. package/dist/schemas/unknown-schema.js +3 -0
  139. package/dist/schemas/unknown-schema.js.map +1 -1
  140. package/dist/schemas/unresolved-schema.d.ts +1 -0
  141. package/dist/schemas/unresolved-schema.js +3 -0
  142. package/dist/schemas/unresolved-schema.js.map +1 -1
  143. package/dist/schemas/variable-like.d.ts +6 -1
  144. package/dist/schemas/variable-like.js +16 -2
  145. package/dist/schemas/variable-like.js.map +1 -1
  146. package/package.json +2 -2
  147. package/schema-node.ts +4 -2
  148. package/schemas/array-literal-expression.ts +5 -0
  149. package/schemas/class.ts +52 -4
  150. package/schemas/conditional-type.ts +9 -0
  151. package/schemas/decorator.ts +14 -1
  152. package/schemas/docs/doc.ts +20 -0
  153. package/schemas/docs/property-like-tag.ts +6 -0
  154. package/schemas/docs/return-tag.ts +6 -0
  155. package/schemas/docs/tag.ts +4 -0
  156. package/schemas/enum-member.ts +16 -0
  157. package/schemas/enum.ts +27 -3
  158. package/schemas/export.ts +42 -4
  159. package/schemas/expression-with-arguments.ts +11 -0
  160. package/schemas/function-like.ts +37 -4
  161. package/schemas/get-accessor.ts +15 -2
  162. package/schemas/ignored.ts +4 -0
  163. package/schemas/index-signature.ts +7 -0
  164. package/schemas/indexed-access-type.ts +7 -0
  165. package/schemas/inference-type.ts +16 -0
  166. package/schemas/interface.ts +41 -3
  167. package/schemas/keyword-type.ts +4 -0
  168. package/schemas/literal-type.ts +4 -0
  169. package/schemas/literal-value.ts +4 -0
  170. package/schemas/module.ts +25 -5
  171. package/schemas/named-tuple.ts +6 -2
  172. package/schemas/object-literal-expression.ts +11 -2
  173. package/schemas/parameter.ts +40 -0
  174. package/schemas/parenthesized-type.ts +6 -2
  175. package/schemas/property-assignment.ts +16 -2
  176. package/schemas/set-accessor.ts +5 -0
  177. package/schemas/template-literal-type-span.ts +6 -2
  178. package/schemas/template-literal-type.ts +7 -2
  179. package/schemas/this-type.ts +4 -0
  180. package/schemas/tuple-type.ts +6 -2
  181. package/schemas/type-array.ts +6 -2
  182. package/schemas/type-intersection.ts +6 -2
  183. package/schemas/type-literal.ts +22 -0
  184. package/schemas/type-operator.ts +6 -2
  185. package/schemas/type-predicate.ts +15 -2
  186. package/schemas/type-query.ts +6 -2
  187. package/schemas/type-ref.ts +23 -6
  188. package/schemas/type-union.ts +13 -2
  189. package/schemas/type.ts +16 -2
  190. package/schemas/unimplemented-schema.ts +4 -0
  191. package/schemas/unknown-schema.ts +4 -0
  192. package/schemas/unresolved-schema.ts +4 -0
  193. package/schemas/variable-like.ts +20 -2
  194. package/dist/tsconfig.json +0 -37
  195. package/tsconfig.json +0 -37
@@ -18,6 +18,12 @@ export class ReturnTagSchema extends TagSchema {
18
18
  return `@${this.tagName}${comment}`;
19
19
  }
20
20
 
21
+ toFullSignature(options?: { showDocs?: boolean }): string {
22
+ const typeStr = this.type ? ` {${this.type.toFullSignature(options)}}` : '';
23
+ const comment = this.comment ? ` ${this.comment}` : '';
24
+ return `@${this.tagName}${typeStr}${comment}`;
25
+ }
26
+
21
27
  toObject() {
22
28
  return {
23
29
  ...super.toObject(),
@@ -13,6 +13,10 @@ export class TagSchema extends SchemaNode {
13
13
  return `@${this.tagName}${comment}`;
14
14
  }
15
15
 
16
+ toFullSignature(): string {
17
+ return this.toString();
18
+ }
19
+
16
20
  static fromObject(obj: Record<string, any>): TagSchema {
17
21
  const location = obj.location;
18
22
  const tagName = obj.tagName;
@@ -20,6 +20,22 @@ export class EnumMemberSchema extends SchemaNode {
20
20
  return `${this.name}=${this.value}`;
21
21
  }
22
22
 
23
+ toFullSignature(options?: { showDocs?: boolean }): string {
24
+ let result = '';
25
+
26
+ if (options?.showDocs && this.doc) {
27
+ result += `${this.doc.toFullSignature()}\n`;
28
+ }
29
+
30
+ if (this.value !== undefined) {
31
+ result += `${this.name} = ${this.value}`;
32
+ } else {
33
+ result += `${this.name}`;
34
+ }
35
+
36
+ return result;
37
+ }
38
+
23
39
  toObject() {
24
40
  return {
25
41
  ...super.toObject(),
package/schemas/enum.ts CHANGED
@@ -23,9 +23,33 @@ export class EnumSchema extends SchemaNode {
23
23
  return this.members;
24
24
  }
25
25
 
26
- toString() {
27
- const membersStr = this.members.map((m) => `* ${m.toString()}`).join('\n');
28
- return `${chalk.bold.underline(this.name)}\n${membersStr}`;
26
+ toString(options) {
27
+ const boldUnderline = options?.color ? chalk.bold.underline : (str: string) => str;
28
+ const membersStr = this.members.map((m) => `* ${m.toString(options)}`).join('\n');
29
+ return `${boldUnderline(this.name)}\n${membersStr}`;
30
+ }
31
+
32
+ toFullSignature(options?: { showDocs?: boolean }): string {
33
+ let result = '';
34
+
35
+ if (options?.showDocs && this.doc) {
36
+ result += `${this.doc.toFullSignature()}\n`;
37
+ }
38
+
39
+ result += `enum ${this.name} {\n`;
40
+
41
+ const membersStr = this.members
42
+ .map((member) => {
43
+ const memberStr = member.toFullSignature(options);
44
+ return ` ${memberStr}`;
45
+ })
46
+ .join(',\n');
47
+
48
+ result += `${membersStr}\n`;
49
+
50
+ result += `}`;
51
+
52
+ return result;
29
53
  }
30
54
 
31
55
  toObject() {
package/schemas/export.ts CHANGED
@@ -6,6 +6,7 @@ export class ExportSchema extends SchemaNode {
6
6
  alias?: string;
7
7
  exportNode: SchemaNode;
8
8
  readonly doc?: DocSchema;
9
+ readonly signature?: string;
9
10
 
10
11
  constructor(
11
12
  readonly location: SchemaLocation,
@@ -18,13 +19,50 @@ export class ExportSchema extends SchemaNode {
18
19
  this.exportNode = exportNode;
19
20
  this.alias = alias;
20
21
  this.doc = doc;
22
+ this.signature = exportNode.signature || this.toFullSignature();
21
23
  }
22
24
 
23
- toString() {
24
- if (this.alias) {
25
- return `${this.name} as ${this.alias}`;
25
+ toString(options?: { color?: boolean }): string {
26
+ let signature = '';
27
+
28
+ const alias = this.alias || this.name;
29
+ const originalName = this.exportNode.name || this.name;
30
+
31
+ if (alias !== originalName) {
32
+ signature += `export { ${originalName} as ${alias} };\n`;
33
+ } else {
34
+ signature += `export { ${originalName} };\n`;
26
35
  }
27
- return `${this.name}`;
36
+
37
+ const exportNodeSignature = this.exportNode.toString(options);
38
+
39
+ signature += `\n${exportNodeSignature}`;
40
+
41
+ return signature;
42
+ }
43
+
44
+ toFullSignature(options?: { showDocs?: boolean }): string {
45
+ let signature = '';
46
+
47
+ if (options?.showDocs && this.doc) {
48
+ const docString = this.doc.toFullSignature();
49
+ signature += `${docString}\n`;
50
+ }
51
+
52
+ const alias = this.alias || this.name;
53
+ const originalName = this.exportNode.name || this.name;
54
+
55
+ if (alias !== originalName) {
56
+ signature += `export { ${originalName} as ${alias} };\n`;
57
+ } else {
58
+ signature += `export { ${originalName} };\n`;
59
+ }
60
+
61
+ const exportNodeSignature = this.exportNode.toFullSignature(options);
62
+
63
+ signature += `\n${exportNodeSignature}`;
64
+
65
+ return signature;
28
66
  }
29
67
 
30
68
  toObject() {
@@ -20,6 +20,17 @@ export class ExpressionWithTypeArgumentsSchema extends SchemaNode {
20
20
  return this.name;
21
21
  }
22
22
 
23
+ toFullSignature(options?: { showDocs?: boolean }): string {
24
+ let result = this.name;
25
+
26
+ if (this.typeArgs && this.typeArgs.length > 0) {
27
+ const typeArgsStr = this.typeArgs.map((arg) => arg.toFullSignature(options)).join(', ');
28
+ result += `<${typeArgsStr}>`;
29
+ }
30
+
31
+ return result;
32
+ }
33
+
23
34
  toObject() {
24
35
  return {
25
36
  ...super.toObject(),
@@ -47,13 +47,46 @@ export class FunctionLikeSchema extends SchemaNode {
47
47
  return [...this.params, this.returnType, ...(this.decorators || [])];
48
48
  }
49
49
 
50
- toString() {
50
+ toString({ color }) {
51
+ const bold = color ? chalk.bold : (text: string) => text;
51
52
  const paramsStr = this.params.map((param) => param.toString()).join(', ');
52
53
  const typeParamsStr = this.typeParams ? `<${this.typeParams.join(', ')}>` : '';
53
- const decoratorsStr = this.decorators?.map((decorator) => decorator.toString()).join('\n');
54
- return `${this.decorators ? `${decoratorsStr}\n` : ''}${this.modifiersToString()}${typeParamsStr}${chalk.bold(
54
+ const decoratorsStr = this.decorators?.map((decorator) => decorator.toString({ color })).join('\n');
55
+ return `${this.decorators ? `${decoratorsStr}\n` : ''}${this.modifiersToString()}${typeParamsStr}${bold(
55
56
  this.name
56
- )}(${paramsStr}): ${this.returnType.toString()}`;
57
+ )}(${paramsStr}): ${this.returnType.toString({ color })}`;
58
+ }
59
+
60
+ toFullSignature(options?: { showDocs?: boolean }): string {
61
+ let result = '';
62
+ if (options?.showDocs && this.doc) {
63
+ result += `${this.doc.toFullSignature()}\n`;
64
+ }
65
+ const decoratorsStr = this.decorators?.map((decorator) => decorator.toString()).join('\n');
66
+ if (decoratorsStr) {
67
+ result += `${decoratorsStr}\n`;
68
+ }
69
+ const modifiersStr = this.modifiersToString();
70
+ const typeParamsStr = this.typeParams ? `<${this.typeParams.join(', ')}>` : '';
71
+ const paramsStr = this.params
72
+ .map((param) => {
73
+ let paramStr = '';
74
+ if (param.isSpread) {
75
+ paramStr += '...';
76
+ }
77
+ paramStr += param.name;
78
+ if (param.isOptional) {
79
+ paramStr += '?';
80
+ }
81
+ paramStr += `: ${param.type.toString()}`;
82
+ if (param.defaultValue !== undefined) {
83
+ paramStr += ` = ${param.defaultValue}`;
84
+ }
85
+ return paramStr;
86
+ })
87
+ .join(', ');
88
+ result += `${modifiersStr}${this.name}${typeParamsStr}(${paramsStr}): ${this.returnType.toString()}`;
89
+ return result;
57
90
  }
58
91
 
59
92
  isDeprecated(): boolean {
@@ -16,8 +16,21 @@ export class GetAccessorSchema extends SchemaNode {
16
16
  return [this.type];
17
17
  }
18
18
 
19
- toString() {
20
- return `get ${chalk.bold(this.name)}(): ${this.type.toString()}`;
19
+ toString(options?: { color?: boolean }): string {
20
+ const bold = options?.color ? chalk.bold : (x: string) => x;
21
+ return `get ${bold(this.name)}(): ${this.type.toString(options)}`;
22
+ }
23
+
24
+ toFullSignature(options?: { showDocs?: boolean }): string {
25
+ let result = '';
26
+
27
+ if (options?.showDocs && this.doc) {
28
+ result += `${this.doc.toFullSignature()}\n`;
29
+ }
30
+
31
+ result += `get ${this.name}(): ${this.type.toFullSignature(options)}`;
32
+
33
+ return result;
21
34
  }
22
35
 
23
36
  toObject() {
@@ -25,6 +25,10 @@ export class IgnoredSchema extends SchemaNode {
25
25
  return '';
26
26
  }
27
27
 
28
+ toFullSignature(): string {
29
+ return '';
30
+ }
31
+
28
32
  toObject() {
29
33
  return {
30
34
  ...super.toObject(),
@@ -20,6 +20,13 @@ export class IndexSignatureSchema extends SchemaNode {
20
20
  return `[${this.keyType.toString()}]: ${this.valueType.toString()}`;
21
21
  }
22
22
 
23
+ toFullSignature(options?: { showDocs?: boolean }): string {
24
+ const keyTypeStr = this.keyType.toFullSignature(options);
25
+ const valueTypeStr = this.valueType.toFullSignature(options);
26
+
27
+ return `[${keyTypeStr}]: ${valueTypeStr}`;
28
+ }
29
+
23
30
  toObject() {
24
31
  return {
25
32
  ...super.toObject(),
@@ -19,6 +19,13 @@ export class IndexedAccessSchema extends SchemaNode {
19
19
  return `${this.objectType.toString()}[${this.indexType.toString()}]`;
20
20
  }
21
21
 
22
+ toFullSignature(options?: { showDocs?: boolean }): string {
23
+ const objectTypeStr = this.objectType.toFullSignature(options);
24
+ const indexTypeStr = this.indexType.toFullSignature(options);
25
+
26
+ return `${objectTypeStr}[${indexTypeStr}]`;
27
+ }
28
+
22
29
  toObject() {
23
30
  return {
24
31
  ...super.toObject(),
@@ -22,6 +22,22 @@ export class InferenceTypeSchema extends SchemaNode {
22
22
  return this.type;
23
23
  }
24
24
 
25
+ toFullSignature(): string {
26
+ let result = '';
27
+
28
+ if (this.name && this.name !== this.type) {
29
+ result += `${this.name}: `;
30
+ }
31
+
32
+ result += this.type;
33
+
34
+ if (this.defaultValue !== undefined) {
35
+ result += ` = ${this.defaultValue}`;
36
+ }
37
+
38
+ return result;
39
+ }
40
+
25
41
  toObject() {
26
42
  return {
27
43
  ...super.toObject(),
@@ -26,9 +26,47 @@ export class InterfaceSchema extends SchemaNode {
26
26
  return this.members;
27
27
  }
28
28
 
29
- toString() {
30
- const membersStr = this.members.map((m) => `* ${m.toString()}`).join('\n');
31
- return `${chalk.bold.underline(this.name)}\n${membersStr}`;
29
+ toString(options?: { color?: boolean }): string {
30
+ const boldUnderline = options?.color ? chalk.bold.underline : (str: string) => str;
31
+ const membersStr = this.members.map((m) => `* ${m.toString(options)}`).join('\n');
32
+ return `${boldUnderline(this.name)}\n${membersStr}`;
33
+ }
34
+
35
+ toFullSignature(options?: { showDocs?: boolean }): string {
36
+ let result = '';
37
+
38
+ if (options?.showDocs && this.doc) {
39
+ result += `${this.doc.toFullSignature()}\n`;
40
+ }
41
+
42
+ let interfaceDeclaration = `interface ${this.name}`;
43
+
44
+ if (this.typeParams && this.typeParams.length > 0) {
45
+ interfaceDeclaration += `<${this.typeParams.join(', ')}>`;
46
+ }
47
+
48
+ if (this.extendsNodes && this.extendsNodes.length > 0) {
49
+ const extendsStr = this.extendsNodes.map((node) => node.toFullSignature(options)).join(', ');
50
+ interfaceDeclaration += ` extends ${extendsStr}`;
51
+ }
52
+
53
+ result += `${interfaceDeclaration} {\n`;
54
+
55
+ const membersStr = this.members
56
+ .map((member) => {
57
+ const memberStr = member.toFullSignature(options);
58
+ return memberStr
59
+ .split('\n')
60
+ .map((line) => ` ${line}`)
61
+ .join('\n');
62
+ })
63
+ .join('\n');
64
+
65
+ result += `${membersStr}\n`;
66
+
67
+ result += `}`;
68
+
69
+ return result;
32
70
  }
33
71
 
34
72
  toObject() {
@@ -12,6 +12,10 @@ export class KeywordTypeSchema extends SchemaNode {
12
12
  return this.name;
13
13
  }
14
14
 
15
+ toFullSignature(): string {
16
+ return this.toString();
17
+ }
18
+
15
19
  toObject() {
16
20
  return {
17
21
  ...super.toObject(),
@@ -19,6 +19,10 @@ export class LiteralTypeSchema extends SchemaNode {
19
19
  return this.name;
20
20
  }
21
21
 
22
+ toFullSignature(): string {
23
+ return this.toString();
24
+ }
25
+
22
26
  static fromObject(obj: Record<string, any>): LiteralTypeSchema {
23
27
  const location = obj.location;
24
28
  const name = obj.name;
@@ -10,6 +10,10 @@ export class LiteralValueSchema extends SchemaNode {
10
10
  return this.value;
11
11
  }
12
12
 
13
+ toFullSignature(): string {
14
+ return this.toString();
15
+ }
16
+
13
17
  toObject() {
14
18
  return {
15
19
  ...super.toObject(),
package/schemas/module.ts CHANGED
@@ -5,11 +5,11 @@ import { ExportSchema } from './export';
5
5
 
6
6
  export class ModuleSchema extends SchemaNode {
7
7
  // exports could either be re exports (export declarations) or nodes with export modifier
8
- exports: (ExportSchema | SchemaNode)[];
8
+ exports: SchemaNode[];
9
9
  internals: SchemaNode[];
10
10
  namespace?: string;
11
11
 
12
- constructor(readonly location: SchemaLocation, exports: (ExportSchema | SchemaNode)[], internals: SchemaNode[]) {
12
+ constructor(readonly location: SchemaLocation, exports: SchemaNode[], internals: SchemaNode[]) {
13
13
  super();
14
14
  this.exports = exports;
15
15
  this.internals = internals;
@@ -30,13 +30,33 @@ export class ModuleSchema extends SchemaNode {
30
30
  }, [] as (ExportSchema | SchemaNode)[]);
31
31
  }
32
32
 
33
- toString() {
33
+ toString(options?: { color?: boolean }) {
34
34
  if (!this.namespace)
35
35
  throw new Error(
36
36
  'toString() should not be called on a module without namespace, make sure this.flatExportsRecursively() is called'
37
37
  );
38
- const exportsStr = this.exports.map((m) => `* ${m.toString()}`).join('\n');
39
- return `${chalk.bold.underline(this.namespace)}\n${exportsStr}`;
38
+ const boldUnderline = options?.color ? chalk.bold.underline : (str: string) => str;
39
+
40
+ const exportsStr = this.exports.map((m) => `* ${m.toString(options)}`).join('\n');
41
+ return `${boldUnderline(this.namespace)}\n${exportsStr}`;
42
+ }
43
+
44
+ toFullSignature(options?: { showDocs?: boolean }): string {
45
+ if (!this.namespace)
46
+ throw new Error(
47
+ 'toFullSignature() should not be called on a module without namespace; make sure this.flatExportsRecursively() is called'
48
+ );
49
+
50
+ const exportsSignatures = this.exports.map((m) => m.toFullSignature(options)).join('\n');
51
+
52
+ let signature = `${this.namespace}\n${exportsSignatures}`;
53
+
54
+ if (options?.showDocs && this.doc) {
55
+ const docString = this.doc.toFullSignature();
56
+ signature = `${docString}\n${signature}`;
57
+ }
58
+
59
+ return signature;
40
60
  }
41
61
 
42
62
  toObject() {
@@ -10,8 +10,12 @@ export class NamedTupleSchema extends SchemaNode {
10
10
  return [this.type];
11
11
  }
12
12
 
13
- toString() {
14
- return `${this.name}: ${this.type.toString()}`;
13
+ toString(options?: { color?: boolean }): string {
14
+ return `${this.name}: ${this.type.toString(options)}`;
15
+ }
16
+
17
+ toFullSignature(options?: { showDocs?: boolean }): string {
18
+ return `${this.name}: ${this.type.toFullSignature(options)}`;
15
19
  }
16
20
 
17
21
  toObject() {
@@ -10,8 +10,17 @@ export class ObjectLiteralExpressionSchema extends SchemaNode {
10
10
  return this.members;
11
11
  }
12
12
 
13
- toString(): string {
14
- return `{\n${this.members.map((member) => `\t${member.toString()}`).join('\n')}\n}`;
13
+ toString(options?: { color?: boolean }): string {
14
+ return `{\n${this.members.map((member) => `\t${member.toString(options)}`).join('\n')}\n}`;
15
+ }
16
+
17
+ toFullSignature(options?: { showDocs?: boolean }): string {
18
+ const membersStr = this.members.map((member) => member.toFullSignature(options)).join(',\n');
19
+
20
+ return `{\n${membersStr
21
+ .split('\n')
22
+ .map((line) => ` ${line}`)
23
+ .join('\n')}\n}`;
15
24
  }
16
25
 
17
26
  toObject() {
@@ -25,6 +25,46 @@ export class ParameterSchema<T extends SchemaNode = SchemaNode> extends SchemaNo
25
25
  return `${this.name}${this.isOptional ? '?' : ''}: ${this.type.toString()}`;
26
26
  }
27
27
 
28
+ toFullSignature(options?: { showDocs?: boolean }): string {
29
+ let paramStr = '';
30
+
31
+ if (options?.showDocs && this.description) {
32
+ paramStr += `/** ${this.description} */\n`;
33
+ }
34
+
35
+ if (this.isSpread) {
36
+ paramStr += '...';
37
+ }
38
+
39
+ let paramName = '';
40
+
41
+ if (this.objectBindingNodes && this.objectBindingNodes.length > 0) {
42
+ const bindingsStr = this.objectBindingNodes.map((node) => node.toFullSignature(options)).join(', ');
43
+ paramName += `{ ${bindingsStr} }`;
44
+ } else {
45
+ paramName += this.name;
46
+ }
47
+
48
+ if (this.isOptional) {
49
+ paramName += '?';
50
+ }
51
+
52
+ paramStr += `${paramName}`;
53
+
54
+ if (this.type && typeof this.type.toString === 'function') {
55
+ const typeName = this.type.toString();
56
+ if (typeName) {
57
+ paramStr += `: ${typeName}`;
58
+ }
59
+ }
60
+
61
+ if (this.defaultValue !== undefined) {
62
+ paramStr += ` = ${this.defaultValue}`;
63
+ }
64
+
65
+ return paramStr;
66
+ }
67
+
28
68
  toObject() {
29
69
  return {
30
70
  ...super.toObject(),
@@ -16,8 +16,12 @@ export class ParenthesizedTypeSchema extends SchemaNode {
16
16
  return [this.type];
17
17
  }
18
18
 
19
- toString() {
20
- return `(${this.type.toString()})`;
19
+ toString(options?: { color?: boolean }): string {
20
+ return `(${this.type.toString(options)})`;
21
+ }
22
+
23
+ toFullSignature(options?: { showDocs?: boolean }): string {
24
+ return `(${this.type.toFullSignature(options)})`;
21
25
  }
22
26
 
23
27
  toObject() {
@@ -12,8 +12,22 @@ export class PropertyAssignmentSchema extends SchemaNode {
12
12
  super();
13
13
  }
14
14
 
15
- toString() {
16
- return `${this.name}: ${this.value.toString()}`;
15
+ toString(options?: { color?: boolean }): string {
16
+ return `${this.name}: ${this.value.toString(options)}`;
17
+ }
18
+
19
+ toFullSignature(options?: { showDocs?: boolean }): string {
20
+ let result = '';
21
+
22
+ if (options?.showDocs && this.doc) {
23
+ result += `${this.doc.toFullSignature()}\n`;
24
+ }
25
+
26
+ const valueStr = this.value.toFullSignature(options);
27
+
28
+ result += `${this.name}: ${valueStr}`;
29
+
30
+ return result;
17
31
  }
18
32
 
19
33
  toObject() {
@@ -23,6 +23,11 @@ export class SetAccessorSchema extends SchemaNode {
23
23
  return `set ${chalk.bold(this.name)}(${this.param.toString()})`;
24
24
  }
25
25
 
26
+ toFullSignature(options?: { showDocs?: boolean }): string {
27
+ const paramStr = this.param.toFullSignature(options);
28
+ return `set ${this.name}(${paramStr})`;
29
+ }
30
+
26
31
  toObject() {
27
32
  return {
28
33
  ...super.toObject(),
@@ -13,8 +13,12 @@ export class TemplateLiteralTypeSpanSchema extends SchemaNode {
13
13
  return [this.type];
14
14
  }
15
15
 
16
- toString() {
17
- return `${this.type.toString()} ${this.literal}`;
16
+ toString(options?: { color?: boolean }) {
17
+ return `${this.type.toString(options)} ${this.literal}`;
18
+ }
19
+
20
+ toFullSignature(options?: { showDocs?: boolean }): string {
21
+ return `${this.type.toFullSignature(options)} ${this.literal}`;
18
22
  }
19
23
 
20
24
  toObject() {
@@ -13,11 +13,16 @@ export class TemplateLiteralTypeSchema extends SchemaNode {
13
13
  this.templateSpans = templateSpans;
14
14
  }
15
15
 
16
- toString() {
17
- const spans = this.templateSpans.map((span) => span.toString()).join('');
16
+ toString(options?: { color?: boolean }) {
17
+ const spans = this.templateSpans.map((span) => span.toString(options)).join('');
18
18
  return `${this.head}${spans}`;
19
19
  }
20
20
 
21
+ toFullSignature(options?: { showDocs?: boolean }): string {
22
+ const spans = this.templateSpans.map((span) => span.toFullSignature(options)).join('');
23
+ return `\`${this.head}${spans}\``;
24
+ }
25
+
21
26
  toObject() {
22
27
  return {
23
28
  ...super.toObject(),
@@ -12,6 +12,10 @@ export class ThisTypeSchema extends SchemaNode {
12
12
  return this.name;
13
13
  }
14
14
 
15
+ toFullSignature() {
16
+ return this.toString();
17
+ }
18
+
15
19
  static fromObject(obj: Record<string, any>): ThisTypeSchema {
16
20
  const location = obj.location;
17
21
  const name = obj.name;
@@ -9,8 +9,12 @@ export class TupleTypeSchema extends SchemaNode {
9
9
  this.elements = elements;
10
10
  }
11
11
 
12
- toString() {
13
- return `[${this.elements.map((elem) => elem.toString()).join(', ')}]`;
12
+ toString(options?: { color?: boolean }) {
13
+ return `[${this.elements.map((elem) => elem.toString(options)).join(', ')}]`;
14
+ }
15
+
16
+ toFullSignature(options?: { showDocs?: boolean }): string {
17
+ return `[${this.elements.map((elem) => elem.toFullSignature(options)).join(', ')}]`;
14
18
  }
15
19
 
16
20
  toObject() {
@@ -13,8 +13,12 @@ export class TypeArraySchema extends SchemaNode {
13
13
  return [this.type];
14
14
  }
15
15
 
16
- toString() {
17
- return `${this.type.toString()}[]`;
16
+ toString(options?: { color?: boolean }) {
17
+ return `${this.type.toString(options)}[]`;
18
+ }
19
+
20
+ toFullSignature(options?: { showDocs?: boolean }): string {
21
+ return `${this.type.toFullSignature(options)}[]`;
18
22
  }
19
23
 
20
24
  toObject() {