@teambit/typescript 0.0.728 → 0.0.731

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 (91) hide show
  1. package/dist/exceptions/transformer-not-found.js +14 -1
  2. package/dist/exceptions/transformer-not-found.js.map +1 -1
  3. package/dist/schema-extractor-context.d.ts +38 -7
  4. package/dist/schema-extractor-context.js +228 -31
  5. package/dist/schema-extractor-context.js.map +1 -1
  6. package/dist/transformers/class-deceleration.d.ts +11 -0
  7. package/dist/transformers/class-deceleration.js +141 -0
  8. package/dist/transformers/class-deceleration.js.map +1 -0
  9. package/dist/transformers/constructor.d.ts +10 -0
  10. package/dist/transformers/constructor.js +70 -0
  11. package/dist/transformers/constructor.js.map +1 -0
  12. package/dist/transformers/export-declaration.d.ts +2 -1
  13. package/dist/transformers/export-declaration.js +64 -13
  14. package/dist/transformers/export-declaration.js.map +1 -1
  15. package/dist/transformers/function-declaration.d.ts +1 -3
  16. package/dist/transformers/function-declaration.js +27 -32
  17. package/dist/transformers/function-declaration.js.map +1 -1
  18. package/dist/transformers/index-signature.d.ts +9 -0
  19. package/dist/transformers/index-signature.js +71 -0
  20. package/dist/transformers/index-signature.js.map +1 -0
  21. package/dist/transformers/index.d.ts +10 -0
  22. package/dist/transformers/index.js +160 -0
  23. package/dist/transformers/index.js.map +1 -1
  24. package/dist/transformers/interface-declaration.d.ts +10 -0
  25. package/dist/transformers/interface-declaration.js +73 -0
  26. package/dist/transformers/interface-declaration.js.map +1 -0
  27. package/dist/transformers/literal-type.d.ts +8 -0
  28. package/dist/transformers/literal-type.js +50 -0
  29. package/dist/transformers/literal-type.js.map +1 -0
  30. package/dist/transformers/method-declaration.d.ts +11 -0
  31. package/dist/transformers/method-declaration.js +94 -0
  32. package/dist/transformers/method-declaration.js.map +1 -0
  33. package/dist/transformers/method-signature.d.ts +10 -0
  34. package/dist/transformers/method-signature.js +81 -0
  35. package/dist/transformers/method-signature.js.map +1 -0
  36. package/dist/transformers/property-declaration.d.ts +11 -0
  37. package/dist/transformers/property-declaration.js +80 -0
  38. package/dist/transformers/property-declaration.js.map +1 -0
  39. package/dist/transformers/property-signature.d.ts +10 -0
  40. package/dist/transformers/property-signature.js +90 -0
  41. package/dist/transformers/property-signature.js.map +1 -0
  42. package/dist/transformers/source-file-transformer.d.ts +2 -1
  43. package/dist/transformers/source-file-transformer.js +23 -3
  44. package/dist/transformers/source-file-transformer.js.map +1 -1
  45. package/dist/transformers/type-alias.d.ts +4 -1
  46. package/dist/transformers/type-alias.js +31 -2
  47. package/dist/transformers/type-alias.js.map +1 -1
  48. package/dist/transformers/utils/get-params.d.ts +4 -0
  49. package/dist/transformers/utils/get-params.js +69 -0
  50. package/dist/transformers/utils/get-params.js.map +1 -0
  51. package/dist/transformers/utils/parse-type-from-quick-info.d.ts +35 -0
  52. package/dist/transformers/utils/parse-type-from-quick-info.js +112 -0
  53. package/dist/transformers/utils/parse-type-from-quick-info.js.map +1 -0
  54. package/dist/transformers/utils/type-node-to-schema.d.ts +4 -0
  55. package/dist/transformers/utils/type-node-to-schema.js +251 -0
  56. package/dist/transformers/utils/type-node-to-schema.js.map +1 -0
  57. package/dist/transformers/variable-declaration.d.ts +11 -0
  58. package/dist/transformers/variable-declaration.js +98 -0
  59. package/dist/transformers/variable-declaration.js.map +1 -0
  60. package/dist/transformers/variable-statement.d.ts +7 -1
  61. package/dist/transformers/variable-statement.js +42 -2
  62. package/dist/transformers/variable-statement.js.map +1 -1
  63. package/dist/typescript.extractor.d.ts +3 -3
  64. package/dist/typescript.extractor.js +7 -4
  65. package/dist/typescript.extractor.js.map +1 -1
  66. package/dist/typescript.main.runtime.js +1 -1
  67. package/dist/typescript.main.runtime.js.map +1 -1
  68. package/exceptions/transformer-not-found.ts +5 -4
  69. package/package-tar/teambit-typescript-0.0.731.tgz +0 -0
  70. package/package.json +15 -15
  71. package/{preview-1652153159767.js → preview-1652498684867.js} +2 -2
  72. package/transformers/class-deceleration.ts +53 -0
  73. package/transformers/constructor.ts +22 -0
  74. package/transformers/export-declaration.ts +42 -13
  75. package/transformers/function-declaration.ts +9 -28
  76. package/transformers/index-signature.ts +22 -0
  77. package/transformers/index.ts +10 -0
  78. package/transformers/interface-declaration.ts +24 -0
  79. package/transformers/literal-type.ts +18 -0
  80. package/transformers/method-declaration.ts +32 -0
  81. package/transformers/method-signature.ts +30 -0
  82. package/transformers/property-declaration.ts +30 -0
  83. package/transformers/property-signature.ts +37 -0
  84. package/transformers/source-file-transformer.ts +6 -6
  85. package/transformers/type-alias.ts +12 -2
  86. package/transformers/utils/get-params.ts +29 -0
  87. package/transformers/utils/parse-type-from-quick-info.ts +84 -0
  88. package/transformers/utils/type-node-to-schema.ts +205 -0
  89. package/transformers/variable-declaration.ts +36 -0
  90. package/transformers/variable-statement.ts +16 -2
  91. package/package-tar/teambit-typescript-0.0.728.tgz +0 -0
@@ -1,6 +1,9 @@
1
1
  import ts, { Node, TypeAliasDeclaration } from 'typescript';
2
+ import { TypeSchema } from '@teambit/semantics.entities.semantic-schema';
2
3
  import { SchemaTransformer } from '../schema-transformer';
4
+ import { SchemaExtractorContext } from '../schema-extractor-context';
3
5
  import { ExportIdentifier } from '../export-identifier';
6
+ import { typeNodeToSchema } from './utils/type-node-to-schema';
4
7
 
5
8
  export class TypeAliasTransformer implements SchemaTransformer {
6
9
  predicate(node: Node) {
@@ -11,7 +14,14 @@ export class TypeAliasTransformer implements SchemaTransformer {
11
14
  return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];
12
15
  }
13
16
 
14
- async transform() {
15
- return {};
17
+ private getName(node: TypeAliasDeclaration): string {
18
+ return node.name.getText();
19
+ }
20
+
21
+ async transform(typeAlias: TypeAliasDeclaration, context: SchemaExtractorContext) {
22
+ const type = await typeNodeToSchema(typeAlias.type, context);
23
+ const info = await context.getQuickInfo(typeAlias.name);
24
+ const displaySig = info?.body?.displayString;
25
+ return new TypeSchema(this.getName(typeAlias), type, displaySig as string);
16
26
  }
17
27
  }
@@ -0,0 +1,29 @@
1
+ import { ParameterSchema, SchemaNode, TypeRefSchema } from '@teambit/semantics.entities.semantic-schema';
2
+ import pMapSeries from 'p-map-series';
3
+ import { ParameterDeclaration, NodeArray } from 'typescript';
4
+ import { SchemaExtractorContext } from '../../schema-extractor-context';
5
+ import { parseTypeFromQuickInfo } from './parse-type-from-quick-info';
6
+ import { typeNodeToSchema } from './type-node-to-schema';
7
+
8
+ export async function getParams(
9
+ parameterNodes: NodeArray<ParameterDeclaration>,
10
+ context: SchemaExtractorContext
11
+ ): Promise<ParameterSchema[]> {
12
+ return pMapSeries(parameterNodes, async (param) => {
13
+ return new ParameterSchema(
14
+ param.name.getText(),
15
+ await getParamType(param, context),
16
+ param.initializer ? param.initializer.getText() : undefined
17
+ );
18
+ });
19
+ }
20
+
21
+ async function getParamType(param: ParameterDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {
22
+ if (param.type) {
23
+ const type = param.type;
24
+ return typeNodeToSchema(type, context);
25
+ }
26
+ const info = await context.getQuickInfo(param.name);
27
+ const parsed = parseTypeFromQuickInfo(info);
28
+ return new TypeRefSchema(parsed || 'any');
29
+ }
@@ -0,0 +1,84 @@
1
+ // eslint-disable-next-line import/no-unresolved
2
+ import protocol from 'typescript/lib/protocol';
3
+
4
+ /**
5
+ * try to parse the type from the quickinfo.
6
+ * this is an error-prone process, we do our best here.
7
+ *
8
+ * an example of a function with many ":"
9
+ * `export function getObj(a: string, func: (b: number) => {}) { return { a: 1, b: 2 } };`
10
+ * which produce the following quickinfo:
11
+ * ```ts
12
+ * function getObj(a: string, func: (b: number) => {}): {
13
+ * a: number;
14
+ * b: number;
15
+ * }
16
+ * ```
17
+ *
18
+ * some examples of quickinfo:
19
+ *
20
+ * function ts.signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node | undefined, flags?: TypeFormatFlags): SymbolDisplayPart[]
21
+ *
22
+ * const enum ts.TypeFormatFlags
23
+ *
24
+ * (method) ts.TypeChecker.writeSignature(signature: Signature, enclosingDeclaration?: Node | undefined, flags?: TypeFormatFlags | undefined, kind?: SignatureKind | undefined, writer?: EmitTextWriter | undefined): string
25
+ *
26
+ * const obj: {
27
+ * a: number;
28
+ * b: number;
29
+ * }
30
+ *
31
+ * function getObj(a: string): {
32
+ * a: number;
33
+ * b: number;
34
+ * }
35
+ */
36
+ export function parseTypeFromQuickInfo(quickInfo: protocol.QuickInfoResponse | undefined): string {
37
+ if (!quickInfo?.body?.displayString) return '';
38
+ const displayString = quickInfo.body.displayString;
39
+ const splitByColon = displayString.split(':');
40
+ switch (quickInfo.body.kind) {
41
+ case 'const':
42
+ case 'property':
43
+ case 'let':
44
+ case 'var': {
45
+ const [, ...tail] = splitByColon;
46
+ return tail.join(':').trim();
47
+ }
48
+ case 'method':
49
+ case 'function': {
50
+ const split = displayString.split('): ');
51
+ if (split.length !== 2) {
52
+ throw new Error(`quickinfo of a function below was not implemented.\n${displayString}`);
53
+ }
54
+ return split[1].trim();
55
+ }
56
+ case 'alias': {
57
+ // e.g. (alias) class BuilderService\nimport BuilderService
58
+ // e.g. '(alias) type Serializable = {\n' +
59
+ // ' toString(): string;\n' +
60
+ // '}\n' +
61
+ // 'import Serializable'
62
+ const firstLine = displayString.split('\n')[0];
63
+ const splitBySpace = firstLine.trim().split(' ');
64
+ // first two are alias keyword and alias type
65
+ const [, , typeName] = splitBySpace;
66
+ return typeName;
67
+ }
68
+ case 'type': {
69
+ // e.g. `type TaskSlot = SlotRegistry<BuildTask[]>`
70
+ const splitByEqual = displayString.split('=');
71
+ const [, ...tail] = splitByEqual;
72
+ return tail.join('=').trim();
73
+ }
74
+ default:
75
+ return splitByColon[splitByColon.length - 1].trim();
76
+ }
77
+ }
78
+
79
+ export function parseReturnTypeFromQuickInfo(quickInfo: protocol.QuickInfoResponse | undefined): string {
80
+ if (!quickInfo) return '';
81
+ const typeStr = parseTypeFromQuickInfo(quickInfo);
82
+ const array = typeStr.split('=>');
83
+ return array[array.length - 1].trim();
84
+ }
@@ -0,0 +1,205 @@
1
+ import {
2
+ TypeNode,
3
+ SyntaxKind,
4
+ KeywordTypeNode,
5
+ FunctionTypeNode,
6
+ TypeQueryNode,
7
+ TypeReferenceNode,
8
+ ArrayTypeNode,
9
+ TypeOperatorNode,
10
+ TupleTypeNode,
11
+ IntersectionTypeNode,
12
+ UnionTypeNode,
13
+ TypeLiteralNode,
14
+ } from 'typescript';
15
+ import {
16
+ SchemaNode,
17
+ TypeIntersectionSchema,
18
+ TypeUnionSchema,
19
+ TypeLiteralSchema,
20
+ FunctionSchema,
21
+ TypeQuerySchema,
22
+ LiteralTypeSchema,
23
+ KeywordTypeSchema,
24
+ TypeArraySchema,
25
+ TypeOperatorSchema,
26
+ TupleTypeSchema,
27
+ } from '@teambit/semantics.entities.semantic-schema';
28
+ import pMapSeries from 'p-map-series';
29
+ import { SchemaExtractorContext } from '../../schema-extractor-context';
30
+ import { getParams } from './get-params';
31
+
32
+ // eslint-disable-next-line complexity
33
+ export async function typeNodeToSchema(node: TypeNode, context: SchemaExtractorContext): Promise<SchemaNode> {
34
+ if (isKeywordType(node)) {
35
+ return new KeywordTypeSchema(node.getText());
36
+ }
37
+ switch (node.kind) {
38
+ case SyntaxKind.IntersectionType:
39
+ return intersectionType(node as IntersectionTypeNode, context);
40
+ case SyntaxKind.UnionType:
41
+ return unionType(node as UnionTypeNode, context);
42
+ case SyntaxKind.TypeReference:
43
+ return typeReference(node as TypeReferenceNode, context);
44
+ case SyntaxKind.TypeLiteral:
45
+ return typeLiteral(node as TypeLiteralNode, context);
46
+ case SyntaxKind.LiteralType: // e.g. string/boolean
47
+ return new LiteralTypeSchema(node.getText());
48
+ case SyntaxKind.FunctionType:
49
+ return functionType(node as FunctionTypeNode, context);
50
+ case SyntaxKind.TypeQuery:
51
+ return typeQuery(node as TypeQueryNode, context);
52
+ case SyntaxKind.ArrayType:
53
+ return arrayType(node as ArrayTypeNode, context);
54
+ case SyntaxKind.TypeOperator:
55
+ return typeOperator(node as TypeOperatorNode, context);
56
+ case SyntaxKind.TupleType:
57
+ return tupleType(node as TupleTypeNode, context);
58
+ case SyntaxKind.TypePredicate:
59
+ case SyntaxKind.ConstructorType:
60
+ case SyntaxKind.NamedTupleMember:
61
+ case SyntaxKind.OptionalType:
62
+ case SyntaxKind.RestType:
63
+ case SyntaxKind.ConditionalType:
64
+ case SyntaxKind.InferType:
65
+ case SyntaxKind.ParenthesizedType:
66
+ case SyntaxKind.ThisType:
67
+ case SyntaxKind.IndexedAccessType:
68
+ case SyntaxKind.MappedType:
69
+ case SyntaxKind.TemplateLiteralType:
70
+ case SyntaxKind.TemplateLiteralTypeSpan:
71
+ case SyntaxKind.ImportType:
72
+ case SyntaxKind.ExpressionWithTypeArguments:
73
+ case SyntaxKind.JSDocTypeExpression:
74
+ case SyntaxKind.JSDocAllType:
75
+ case SyntaxKind.JSDocUnknownType:
76
+ case SyntaxKind.JSDocNonNullableType:
77
+ case SyntaxKind.JSDocNullableType:
78
+ case SyntaxKind.JSDocOptionalType:
79
+ case SyntaxKind.JSDocFunctionType:
80
+ case SyntaxKind.JSDocVariadicType:
81
+ case SyntaxKind.JSDocNamepathType:
82
+ case SyntaxKind.JSDocSignature:
83
+ case SyntaxKind.JSDocTypeLiteral:
84
+ throw new Error(`TypeNode "${SyntaxKind[node.kind]}" was not implemented yet.
85
+ context: ${node.getText()}`);
86
+ default:
87
+ throw new Error(`Node "${SyntaxKind[node.kind]}" is not a TypeNode.
88
+ context: ${node.getText()}`);
89
+ }
90
+ }
91
+
92
+ /**
93
+ * whether it's kind of `ts.KeywordTypeSyntaxKind`
94
+ */
95
+ function isKeywordType(node: TypeNode): node is KeywordTypeNode {
96
+ switch (node.kind) {
97
+ case SyntaxKind.AnyKeyword:
98
+ case SyntaxKind.BigIntKeyword:
99
+ case SyntaxKind.BooleanKeyword:
100
+ case SyntaxKind.IntrinsicKeyword:
101
+ case SyntaxKind.NeverKeyword:
102
+ case SyntaxKind.NumberKeyword:
103
+ case SyntaxKind.ObjectKeyword:
104
+ case SyntaxKind.StringKeyword:
105
+ case SyntaxKind.SymbolKeyword:
106
+ case SyntaxKind.UndefinedKeyword:
107
+ case SyntaxKind.UnknownKeyword:
108
+ case SyntaxKind.VoidKeyword:
109
+ return true;
110
+ default:
111
+ return false;
112
+ }
113
+ }
114
+
115
+ async function intersectionType(node: IntersectionTypeNode, context: SchemaExtractorContext) {
116
+ const types = await pMapSeries(node.types, async (type) => {
117
+ const typeSchema = await typeNodeToSchema(type, context);
118
+ return typeSchema;
119
+ });
120
+ return new TypeIntersectionSchema(types);
121
+ }
122
+
123
+ async function unionType(node: UnionTypeNode, context: SchemaExtractorContext) {
124
+ const types = await pMapSeries(node.types, async (type) => {
125
+ const typeSchema = await typeNodeToSchema(type, context);
126
+ return typeSchema;
127
+ });
128
+ return new TypeUnionSchema(types);
129
+ }
130
+
131
+ /**
132
+ * not to be confused with "LiteralType", which is string/boolean/null.
133
+ * this "TypeLiteral" is an object with properties, such as: `{ a: string; b: number }`, similar to Interface.
134
+ */
135
+ async function typeLiteral(node: TypeLiteralNode, context: SchemaExtractorContext) {
136
+ const members = await pMapSeries(node.members, async (member) => {
137
+ const typeSchema = await context.computeSchema(member);
138
+ return typeSchema;
139
+ });
140
+ return new TypeLiteralSchema(members);
141
+ }
142
+
143
+ /**
144
+ * In the following example, `AriaButtonProps` is a type reference
145
+ * ```ts
146
+ * import type { AriaButtonProps } from '@react-types/button';
147
+ * export type ButtonProps = AriaButtonProps & { a: string };
148
+ * ```
149
+ */
150
+ async function typeReference(node: TypeReferenceNode, context: SchemaExtractorContext) {
151
+ const name = node.typeName.getText();
152
+ const type = await context.resolveType(node, name, false);
153
+ return type;
154
+ }
155
+
156
+ async function functionType(node: FunctionTypeNode, context: SchemaExtractorContext): Promise<SchemaNode> {
157
+ const name = node.name?.getText() || '';
158
+ const params = await getParams(node.parameters, context);
159
+ const returnType = await typeNodeToSchema(node.type, context);
160
+ return new FunctionSchema(name, params, returnType, '');
161
+ }
162
+
163
+ /**
164
+ * e.g. `typeof Foo`
165
+ */
166
+ async function typeQuery(node: TypeQueryNode, context: SchemaExtractorContext) {
167
+ const displaySig = await context.getQuickInfoDisplayString(node.exprName);
168
+ const type = await context.resolveType(node.exprName, node.exprName.getText(), false);
169
+ return new TypeQuerySchema(type, displaySig);
170
+ }
171
+
172
+ async function arrayType(node: ArrayTypeNode, context: SchemaExtractorContext) {
173
+ const type = await typeNodeToSchema(node.elementType, context);
174
+ return new TypeArraySchema(type);
175
+ }
176
+
177
+ /**
178
+ * e.g. keyof typeof Foo
179
+ */
180
+ async function typeOperator(node: TypeOperatorNode, context: SchemaExtractorContext) {
181
+ const operatorName = getOperatorName(node.operator);
182
+ const type = await typeNodeToSchema(node.type, context);
183
+ return new TypeOperatorSchema(operatorName, type);
184
+ }
185
+
186
+ function getOperatorName(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword) {
187
+ switch (operator) {
188
+ case SyntaxKind.KeyOfKeyword:
189
+ return 'keyof';
190
+ case SyntaxKind.UniqueKeyword:
191
+ return 'unique';
192
+ case SyntaxKind.ReadonlyKeyword:
193
+ return 'readonly';
194
+ default:
195
+ throw new Error(`getOperatorName: unable to find operator name for ${operator}`);
196
+ }
197
+ }
198
+
199
+ async function tupleType(node: TupleTypeNode, context: SchemaExtractorContext) {
200
+ const elements = await pMapSeries(node.elements, async (elem) => {
201
+ const typeSchema = await typeNodeToSchema(elem, context);
202
+ return typeSchema;
203
+ });
204
+ return new TupleTypeSchema(elements);
205
+ }
@@ -0,0 +1,36 @@
1
+ import { SchemaNode, VariableSchema, FunctionSchema } from '@teambit/semantics.entities.semantic-schema';
2
+ import ts, { Node, VariableDeclaration as VariableDeclarationNode, ArrowFunction } from 'typescript';
3
+ import { SchemaTransformer } from '../schema-transformer';
4
+ import { SchemaExtractorContext } from '../schema-extractor-context';
5
+ import { ExportIdentifier } from '../export-identifier';
6
+ import { getParams } from './utils/get-params';
7
+ import { parseReturnTypeFromQuickInfo, parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';
8
+
9
+ export class VariableDeclaration implements SchemaTransformer {
10
+ predicate(node: Node) {
11
+ return node.kind === ts.SyntaxKind.VariableDeclaration;
12
+ }
13
+
14
+ getName(node: VariableDeclarationNode) {
15
+ return node.name.getText();
16
+ }
17
+
18
+ async getIdentifiers(node: VariableDeclarationNode) {
19
+ return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];
20
+ }
21
+
22
+ async transform(varDec: VariableDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {
23
+ const name = this.getName(varDec);
24
+ const info = await context.getQuickInfo(varDec.name);
25
+ const displaySig = info?.body?.displayString || '';
26
+ if (varDec.initializer?.kind === ts.SyntaxKind.ArrowFunction) {
27
+ const args = await getParams((varDec.initializer as ArrowFunction).parameters, context);
28
+ const typeStr = parseReturnTypeFromQuickInfo(info);
29
+ const returnType = await context.resolveType(varDec, typeStr);
30
+ return new FunctionSchema(name, args, returnType, displaySig);
31
+ }
32
+ const typeStr = parseTypeFromQuickInfo(info);
33
+ const type = await context.resolveType(varDec, typeStr);
34
+ return new VariableSchema(name, displaySig, type);
35
+ }
36
+ }
@@ -1,7 +1,15 @@
1
+ import { SchemaNode, Module } from '@teambit/semantics.entities.semantic-schema';
2
+ import { compact } from 'lodash';
3
+ import pMapSeries from 'p-map-series';
1
4
  import ts, { Node, VariableStatement } from 'typescript';
2
5
  import { SchemaTransformer } from '../schema-transformer';
6
+ import { SchemaExtractorContext } from '../schema-extractor-context';
3
7
  import { ExportIdentifier } from '../export-identifier';
4
8
 
9
+ /**
10
+ * variable statement is a collection of variable declarations.
11
+ * e.g. `export const a = 1, b = () => {}, c = {};`
12
+ */
5
13
  export class VariableStatementTransformer implements SchemaTransformer {
6
14
  predicate(node: Node) {
7
15
  return node.kind === ts.SyntaxKind.VariableStatement;
@@ -13,7 +21,13 @@ export class VariableStatementTransformer implements SchemaTransformer {
13
21
  });
14
22
  }
15
23
 
16
- async transform() {
17
- return {};
24
+ async transform(node: VariableStatement, context: SchemaExtractorContext): Promise<SchemaNode> {
25
+ const schemas = await pMapSeries(node.declarationList.declarations, async (dec) => {
26
+ // this will get the schema from variable-declaration
27
+ const schema = await context.visitDefinition(dec.name);
28
+ return schema;
29
+ });
30
+ // @todo: find a better way to return an array of SchemaNode. this is not really a module
31
+ return new Module(compact(schemas));
18
32
  }
19
33
  }