@teambit/semantics.entities.semantic-schema 0.0.69 → 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.
- package/api-schema.ts +49 -1
- package/dist/api-schema.d.ts +7 -44
- package/dist/api-schema.js +36 -1
- package/dist/api-schema.js.map +1 -1
- package/dist/preview-1726715976656.js +7 -0
- package/dist/schema-node.d.ts +12 -2
- package/dist/schema-node.js.map +1 -1
- package/dist/schemas/array-literal-expression.d.ts +3 -0
- package/dist/schemas/array-literal-expression.js +4 -0
- package/dist/schemas/array-literal-expression.js.map +1 -1
- package/dist/schemas/class.d.ts +6 -1
- package/dist/schemas/class.js +41 -4
- package/dist/schemas/class.js.map +1 -1
- package/dist/schemas/conditional-type.d.ts +3 -0
- package/dist/schemas/conditional-type.js +7 -0
- package/dist/schemas/conditional-type.js.map +1 -1
- package/dist/schemas/decorator.d.ts +3 -0
- package/dist/schemas/decorator.js +10 -1
- package/dist/schemas/decorator.js.map +1 -1
- package/dist/schemas/docs/doc.d.ts +1 -0
- package/dist/schemas/docs/doc.js +15 -0
- package/dist/schemas/docs/doc.js.map +1 -1
- package/dist/schemas/docs/property-like-tag.d.ts +3 -0
- package/dist/schemas/docs/property-like-tag.js +5 -0
- package/dist/schemas/docs/property-like-tag.js.map +1 -1
- package/dist/schemas/docs/return-tag.d.ts +3 -0
- package/dist/schemas/docs/return-tag.js +5 -0
- package/dist/schemas/docs/return-tag.js.map +1 -1
- package/dist/schemas/docs/tag.d.ts +3 -1
- package/dist/schemas/docs/tag.js +4 -0
- package/dist/schemas/docs/tag.js.map +1 -1
- package/dist/schemas/enum-member.d.ts +3 -0
- package/dist/schemas/enum-member.js +13 -0
- package/dist/schemas/enum-member.js.map +1 -1
- package/dist/schemas/enum.d.ts +4 -1
- package/dist/schemas/enum.js +20 -3
- package/dist/schemas/enum.js.map +1 -1
- package/dist/schemas/export.d.ts +7 -1
- package/dist/schemas/export.js +31 -4
- package/dist/schemas/export.js.map +1 -1
- package/dist/schemas/expression-with-arguments.d.ts +3 -0
- package/dist/schemas/expression-with-arguments.js +8 -0
- package/dist/schemas/expression-with-arguments.js.map +1 -1
- package/dist/schemas/function-like.d.ts +6 -1
- package/dist/schemas/function-like.js +35 -2
- package/dist/schemas/function-like.js.map +1 -1
- package/dist/schemas/get-accessor.d.ts +6 -1
- package/dist/schemas/get-accessor.js +11 -2
- package/dist/schemas/get-accessor.js.map +1 -1
- package/dist/schemas/ignored.d.ts +1 -0
- package/dist/schemas/ignored.js +3 -0
- package/dist/schemas/ignored.js.map +1 -1
- package/dist/schemas/index-signature.d.ts +3 -0
- package/dist/schemas/index-signature.js +5 -0
- package/dist/schemas/index-signature.js.map +1 -1
- package/dist/schemas/indexed-access-type.d.ts +3 -0
- package/dist/schemas/indexed-access-type.js +5 -0
- package/dist/schemas/indexed-access-type.js.map +1 -1
- package/dist/schemas/inference-type.d.ts +4 -1
- package/dist/schemas/inference-type.js +16 -3
- package/dist/schemas/inference-type.js.map +1 -1
- package/dist/schemas/interface.d.ts +6 -1
- package/dist/schemas/interface.js +31 -3
- package/dist/schemas/interface.js.map +1 -1
- package/dist/schemas/keyword-type.d.ts +1 -0
- package/dist/schemas/keyword-type.js +3 -0
- package/dist/schemas/keyword-type.js.map +1 -1
- package/dist/schemas/literal-type.d.ts +1 -0
- package/dist/schemas/literal-type.js +3 -0
- package/dist/schemas/literal-type.js.map +1 -1
- package/dist/schemas/literal-value.d.ts +1 -0
- package/dist/schemas/literal-value.js +3 -0
- package/dist/schemas/literal-value.js.map +1 -1
- package/dist/schemas/module.d.ts +10 -27
- package/dist/schemas/module.js +15 -3
- package/dist/schemas/module.js.map +1 -1
- package/dist/schemas/named-tuple.d.ts +6 -1
- package/dist/schemas/named-tuple.js +5 -2
- package/dist/schemas/named-tuple.js.map +1 -1
- package/dist/schemas/object-literal-expression.d.ts +6 -1
- package/dist/schemas/object-literal-expression.js +9 -2
- package/dist/schemas/object-literal-expression.js.map +1 -1
- package/dist/schemas/parameter.d.ts +3 -0
- package/dist/schemas/parameter.js +31 -0
- package/dist/schemas/parameter.js.map +1 -1
- package/dist/schemas/parenthesized-type.d.ts +6 -1
- package/dist/schemas/parenthesized-type.js +5 -2
- package/dist/schemas/parenthesized-type.js.map +1 -1
- package/dist/schemas/property-assignment.d.ts +6 -1
- package/dist/schemas/property-assignment.js +11 -2
- package/dist/schemas/property-assignment.js.map +1 -1
- package/dist/schemas/set-accessor.d.ts +3 -0
- package/dist/schemas/set-accessor.js +4 -0
- package/dist/schemas/set-accessor.js.map +1 -1
- package/dist/schemas/template-literal-type-span.d.ts +6 -1
- package/dist/schemas/template-literal-type-span.js +5 -2
- package/dist/schemas/template-literal-type-span.js.map +1 -1
- package/dist/schemas/template-literal-type.d.ts +6 -1
- package/dist/schemas/template-literal-type.js +6 -2
- package/dist/schemas/template-literal-type.js.map +1 -1
- package/dist/schemas/this-type.d.ts +1 -0
- package/dist/schemas/this-type.js +3 -0
- package/dist/schemas/this-type.js.map +1 -1
- package/dist/schemas/tuple-type.d.ts +6 -1
- package/dist/schemas/tuple-type.js +5 -2
- package/dist/schemas/tuple-type.js.map +1 -1
- package/dist/schemas/type-array.d.ts +6 -1
- package/dist/schemas/type-array.js +5 -2
- package/dist/schemas/type-array.js.map +1 -1
- package/dist/schemas/type-intersection.d.ts +6 -1
- package/dist/schemas/type-intersection.js +5 -2
- package/dist/schemas/type-intersection.js.map +1 -1
- package/dist/schemas/type-literal.d.ts +3 -0
- package/dist/schemas/type-literal.js +14 -0
- package/dist/schemas/type-literal.js.map +1 -1
- package/dist/schemas/type-operator.d.ts +6 -1
- package/dist/schemas/type-operator.js +5 -2
- package/dist/schemas/type-operator.js.map +1 -1
- package/dist/schemas/type-predicate.d.ts +6 -1
- package/dist/schemas/type-predicate.js +12 -2
- package/dist/schemas/type-predicate.js.map +1 -1
- package/dist/schemas/type-query.d.ts +6 -1
- package/dist/schemas/type-query.js +5 -2
- package/dist/schemas/type-query.js.map +1 -1
- package/dist/schemas/type-ref.d.ts +6 -1
- package/dist/schemas/type-ref.js +19 -6
- package/dist/schemas/type-ref.js.map +1 -1
- package/dist/schemas/type-union.d.ts +6 -1
- package/dist/schemas/type-union.js +11 -2
- package/dist/schemas/type-union.js.map +1 -1
- package/dist/schemas/type.d.ts +6 -1
- package/dist/schemas/type.js +12 -2
- package/dist/schemas/type.js.map +1 -1
- package/dist/schemas/unimplemented-schema.d.ts +1 -0
- package/dist/schemas/unimplemented-schema.js +3 -0
- package/dist/schemas/unimplemented-schema.js.map +1 -1
- package/dist/schemas/unknown-schema.d.ts +1 -0
- package/dist/schemas/unknown-schema.js +3 -0
- package/dist/schemas/unknown-schema.js.map +1 -1
- package/dist/schemas/unresolved-schema.d.ts +1 -0
- package/dist/schemas/unresolved-schema.js +3 -0
- package/dist/schemas/unresolved-schema.js.map +1 -1
- package/dist/schemas/variable-like.d.ts +6 -1
- package/dist/schemas/variable-like.js +16 -2
- package/dist/schemas/variable-like.js.map +1 -1
- package/package.json +2 -2
- package/schema-node.ts +4 -2
- package/schemas/array-literal-expression.ts +5 -0
- package/schemas/class.ts +52 -4
- package/schemas/conditional-type.ts +9 -0
- package/schemas/decorator.ts +14 -1
- package/schemas/docs/doc.ts +20 -0
- package/schemas/docs/property-like-tag.ts +6 -0
- package/schemas/docs/return-tag.ts +6 -0
- package/schemas/docs/tag.ts +5 -0
- package/schemas/enum-member.ts +16 -0
- package/schemas/enum.ts +27 -3
- package/schemas/export.ts +42 -4
- package/schemas/expression-with-arguments.ts +11 -0
- package/schemas/function-like.ts +37 -4
- package/schemas/get-accessor.ts +15 -2
- package/schemas/ignored.ts +4 -0
- package/schemas/index-signature.ts +7 -0
- package/schemas/indexed-access-type.ts +7 -0
- package/schemas/inference-type.ts +21 -2
- package/schemas/interface.ts +41 -3
- package/schemas/keyword-type.ts +4 -0
- package/schemas/literal-type.ts +4 -0
- package/schemas/literal-value.ts +4 -0
- package/schemas/module.ts +25 -5
- package/schemas/named-tuple.ts +6 -2
- package/schemas/object-literal-expression.ts +11 -2
- package/schemas/parameter.ts +40 -0
- package/schemas/parenthesized-type.ts +6 -2
- package/schemas/property-assignment.ts +16 -2
- package/schemas/set-accessor.ts +5 -0
- package/schemas/template-literal-type-span.ts +6 -2
- package/schemas/template-literal-type.ts +7 -2
- package/schemas/this-type.ts +4 -0
- package/schemas/tuple-type.ts +6 -2
- package/schemas/type-array.ts +6 -2
- package/schemas/type-intersection.ts +6 -2
- package/schemas/type-literal.ts +22 -0
- package/schemas/type-operator.ts +6 -2
- package/schemas/type-predicate.ts +15 -2
- package/schemas/type-query.ts +6 -2
- package/schemas/type-ref.ts +23 -6
- package/schemas/type-union.ts +13 -2
- package/schemas/type.ts +16 -2
- package/schemas/unimplemented-schema.ts +4 -0
- package/schemas/unknown-schema.ts +4 -0
- package/schemas/unresolved-schema.ts +4 -0
- package/schemas/variable-like.ts +20 -2
- package/dist/preview-1714472366682.js +0 -7
- package/dist/tsconfig.json +0 -36
- package/tsconfig.json +0 -36
package/schemas/docs/doc.ts
CHANGED
|
@@ -16,6 +16,26 @@ export class DocSchema extends SchemaNode {
|
|
|
16
16
|
return `${comment}${tags}`;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
toFullSignature(): string {
|
|
20
|
+
const lines: string[] = [];
|
|
21
|
+
|
|
22
|
+
if (this.comment) {
|
|
23
|
+
lines.push(...this.comment.split('\n').map((line) => ` * ${line.trim()}`));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (this.tags && this.tags.length > 0) {
|
|
27
|
+
for (const tag of this.tags) {
|
|
28
|
+
lines.push(` * ${tag.toString().trim()}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (lines.length === 0) {
|
|
33
|
+
return '';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return `/**\n${lines.join('\n')}\n */`;
|
|
37
|
+
}
|
|
38
|
+
|
|
19
39
|
hasTag(tagName: TagName) {
|
|
20
40
|
return Boolean(this.findTag(tagName));
|
|
21
41
|
}
|
|
@@ -18,6 +18,12 @@ export class PropertyLikeTagSchema extends TagSchema {
|
|
|
18
18
|
return `@${this.tagName} ${this.name}${type} ${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} ${this.name}${typeStr}${comment}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
21
27
|
toObject() {
|
|
22
28
|
return {
|
|
23
29
|
...super.toObject(),
|
|
@@ -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(),
|
package/schemas/docs/tag.ts
CHANGED
|
@@ -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;
|
|
@@ -54,4 +58,5 @@ export enum TagName {
|
|
|
54
58
|
return = 'return',
|
|
55
59
|
deprecated = 'deprecated',
|
|
56
60
|
exports = 'exports',
|
|
61
|
+
link = 'link',
|
|
57
62
|
}
|
package/schemas/enum-member.ts
CHANGED
|
@@ -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
|
|
28
|
-
|
|
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
|
-
|
|
25
|
-
|
|
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
|
-
|
|
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(),
|
package/schemas/function-like.ts
CHANGED
|
@@ -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}${
|
|
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 {
|
package/schemas/get-accessor.ts
CHANGED
|
@@ -16,8 +16,21 @@ export class GetAccessorSchema extends SchemaNode {
|
|
|
16
16
|
return [this.type];
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
toString() {
|
|
20
|
-
|
|
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() {
|
package/schemas/ignored.ts
CHANGED
|
@@ -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(),
|
|
@@ -9,7 +9,8 @@ export class InferenceTypeSchema extends SchemaNode {
|
|
|
9
9
|
readonly type: string,
|
|
10
10
|
readonly name?: string,
|
|
11
11
|
readonly defaultValue?: string,
|
|
12
|
-
readonly isSpread?: boolean
|
|
12
|
+
readonly isSpread?: boolean,
|
|
13
|
+
readonly alias?: string
|
|
13
14
|
) {
|
|
14
15
|
super();
|
|
15
16
|
}
|
|
@@ -21,12 +22,29 @@ export class InferenceTypeSchema extends SchemaNode {
|
|
|
21
22
|
return this.type;
|
|
22
23
|
}
|
|
23
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
|
+
|
|
24
41
|
toObject() {
|
|
25
42
|
return {
|
|
26
43
|
...super.toObject(),
|
|
27
44
|
type: this.type,
|
|
28
45
|
defaultValue: this.defaultValue,
|
|
29
46
|
isSpread: this.isSpread,
|
|
47
|
+
alias: this.alias,
|
|
30
48
|
};
|
|
31
49
|
}
|
|
32
50
|
|
|
@@ -36,6 +54,7 @@ export class InferenceTypeSchema extends SchemaNode {
|
|
|
36
54
|
const name = obj.name;
|
|
37
55
|
const defaultValue = obj.defaultValue;
|
|
38
56
|
const isSpread = obj.isSpread;
|
|
39
|
-
|
|
57
|
+
const alias = obj.alias;
|
|
58
|
+
return new InferenceTypeSchema(location, type, name, defaultValue, isSpread, alias);
|
|
40
59
|
}
|
|
41
60
|
}
|
package/schemas/interface.ts
CHANGED
|
@@ -26,9 +26,47 @@ export class InterfaceSchema extends SchemaNode {
|
|
|
26
26
|
return this.members;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
toString() {
|
|
30
|
-
const
|
|
31
|
-
|
|
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() {
|
package/schemas/keyword-type.ts
CHANGED
package/schemas/literal-type.ts
CHANGED
|
@@ -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;
|
package/schemas/literal-value.ts
CHANGED
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:
|
|
8
|
+
exports: SchemaNode[];
|
|
9
9
|
internals: SchemaNode[];
|
|
10
10
|
namespace?: string;
|
|
11
11
|
|
|
12
|
-
constructor(readonly location: SchemaLocation, exports:
|
|
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
|
|
39
|
-
|
|
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() {
|
package/schemas/named-tuple.ts
CHANGED
|
@@ -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() {
|
package/schemas/parameter.ts
CHANGED
|
@@ -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() {
|
package/schemas/set-accessor.ts
CHANGED
|
@@ -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() {
|