@teambit/typescript 0.0.741 → 0.0.744

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 (64) hide show
  1. package/dist/transformers/class-deceleration.js +10 -40
  2. package/dist/transformers/class-deceleration.js.map +1 -1
  3. package/dist/transformers/index.d.ts +0 -6
  4. package/dist/transformers/index.js +0 -96
  5. package/dist/transformers/index.js.map +1 -1
  6. package/dist/transformers/interface-declaration.js +13 -6
  7. package/dist/transformers/interface-declaration.js.map +1 -1
  8. package/dist/transformers/utils/class-element-to-schema.d.ts +4 -0
  9. package/dist/transformers/utils/class-element-to-schema.js +122 -0
  10. package/dist/transformers/utils/class-element-to-schema.js.map +1 -0
  11. package/dist/transformers/utils/jsdoc-to-doc-schema.d.ts +4 -0
  12. package/dist/transformers/utils/jsdoc-to-doc-schema.js +163 -0
  13. package/dist/transformers/utils/jsdoc-to-doc-schema.js.map +1 -0
  14. package/dist/transformers/utils/to-function-schema.d.ts +1 -1
  15. package/dist/transformers/utils/to-function-schema.js +17 -7
  16. package/dist/transformers/utils/to-function-schema.js.map +1 -1
  17. package/dist/transformers/utils/type-element-to-schema.d.ts +7 -0
  18. package/dist/transformers/utils/type-element-to-schema.js +134 -0
  19. package/dist/transformers/utils/type-element-to-schema.js.map +1 -0
  20. package/dist/transformers/utils/type-node-to-schema.js +32 -7
  21. package/dist/transformers/utils/type-node-to-schema.js.map +1 -1
  22. package/dist/transformers/variable-declaration.js +15 -1
  23. package/dist/transformers/variable-declaration.js.map +1 -1
  24. package/dist/typescript.extractor.js +1 -1
  25. package/dist/typescript.extractor.js.map +1 -1
  26. package/dist/typescript.main.runtime.js +1 -1
  27. package/dist/typescript.main.runtime.js.map +1 -1
  28. package/package-tar/teambit-typescript-0.0.744.tgz +0 -0
  29. package/package.json +17 -17
  30. package/{preview-1653494536947.js → preview-1653827208409.js} +2 -2
  31. package/transformers/class-deceleration.ts +7 -26
  32. package/transformers/index.ts +0 -6
  33. package/transformers/interface-declaration.ts +4 -6
  34. package/transformers/utils/class-element-to-schema.ts +61 -0
  35. package/transformers/utils/jsdoc-to-doc-schema.ts +81 -0
  36. package/transformers/utils/to-function-schema.ts +12 -8
  37. package/transformers/utils/type-element-to-schema.ts +72 -0
  38. package/transformers/utils/type-node-to-schema.ts +15 -6
  39. package/transformers/variable-declaration.ts +5 -2
  40. package/dist/transformers/constructor.d.ts +0 -10
  41. package/dist/transformers/constructor.js +0 -70
  42. package/dist/transformers/constructor.js.map +0 -1
  43. package/dist/transformers/index-signature.d.ts +0 -9
  44. package/dist/transformers/index-signature.js +0 -71
  45. package/dist/transformers/index-signature.js.map +0 -1
  46. package/dist/transformers/method-declaration.d.ts +0 -11
  47. package/dist/transformers/method-declaration.js +0 -65
  48. package/dist/transformers/method-declaration.js.map +0 -1
  49. package/dist/transformers/method-signature.d.ts +0 -10
  50. package/dist/transformers/method-signature.js +0 -53
  51. package/dist/transformers/method-signature.js.map +0 -1
  52. package/dist/transformers/property-declaration.d.ts +0 -11
  53. package/dist/transformers/property-declaration.js +0 -80
  54. package/dist/transformers/property-declaration.js.map +0 -1
  55. package/dist/transformers/property-signature.d.ts +0 -10
  56. package/dist/transformers/property-signature.js +0 -72
  57. package/dist/transformers/property-signature.js.map +0 -1
  58. package/package-tar/teambit-typescript-0.0.741.tgz +0 -0
  59. package/transformers/constructor.ts +0 -22
  60. package/transformers/index-signature.ts +0 -22
  61. package/transformers/method-declaration.ts +0 -24
  62. package/transformers/method-signature.ts +0 -23
  63. package/transformers/property-declaration.ts +0 -30
  64. package/transformers/property-signature.ts +0 -28
@@ -40,7 +40,7 @@ function _semanticsEntities() {
40
40
  }
41
41
 
42
42
  function _typescript() {
43
- const data = _interopRequireWildcard(require("typescript"));
43
+ const data = _interopRequireDefault(require("typescript"));
44
44
 
45
45
  _typescript = function () {
46
46
  return data;
@@ -59,30 +59,26 @@ function _exportIdentifier() {
59
59
  return data;
60
60
  }
61
61
 
62
- function _parseTypeFromQuickInfo() {
63
- const data = require("./utils/parse-type-from-quick-info");
62
+ function _jsdocToDocSchema() {
63
+ const data = require("./utils/jsdoc-to-doc-schema");
64
64
 
65
- _parseTypeFromQuickInfo = function () {
65
+ _jsdocToDocSchema = function () {
66
66
  return data;
67
67
  };
68
68
 
69
69
  return data;
70
70
  }
71
71
 
72
- function _getParams() {
73
- const data = require("./utils/get-params");
72
+ function _classElementToSchema() {
73
+ const data = require("./utils/class-element-to-schema");
74
74
 
75
- _getParams = function () {
75
+ _classElementToSchema = function () {
76
76
  return data;
77
77
  };
78
78
 
79
79
  return data;
80
80
  }
81
81
 
82
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
83
-
84
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
85
-
86
82
  class ClassDecelerationTransformer {
87
83
  predicate(node) {
88
84
  return node.kind === _typescript().default.SyntaxKind.ClassDeclaration;
@@ -110,36 +106,10 @@ class ClassDecelerationTransformer {
110
106
  return null;
111
107
  }
112
108
 
113
- if ((0, _typescript().isSemicolonClassElement)(member)) {
114
- return null;
115
- }
116
-
117
- switch (member.kind) {
118
- case _typescript().default.SyntaxKind.GetAccessor:
119
- {
120
- var _info$body;
121
-
122
- const getter = member;
123
- const info = await context.getQuickInfo(getter.name);
124
- const displaySig = (info === null || info === void 0 ? void 0 : (_info$body = info.body) === null || _info$body === void 0 ? void 0 : _info$body.displayString) || '';
125
- const typeStr = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
126
- const type = await context.resolveType(getter, typeStr);
127
- return new (_semanticsEntities().GetAccessorSchema)(context.getLocation(getter), getter.name.getText(), type, displaySig);
128
- }
129
-
130
- case _typescript().default.SyntaxKind.SetAccessor:
131
- {
132
- const setter = member;
133
- const params = await (0, _getParams().getParams)(setter.parameters, context);
134
- const displaySig = await context.getQuickInfoDisplayString(setter.name);
135
- return new (_semanticsEntities().SetAccessorSchema)(context.getLocation(setter), setter.name.getText(), params[0], displaySig);
136
- }
137
-
138
- default:
139
- return context.computeSchema(member);
140
- }
109
+ return (0, _classElementToSchema().classElementToSchema)(member, context);
141
110
  });
142
- return new (_semanticsEntities().ClassSchema)(className, (0, _lodash().compact)(members), context.getLocation(node));
111
+ const doc = await (0, _jsdocToDocSchema().jsDocToDocSchema)(node, context);
112
+ return new (_semanticsEntities().ClassSchema)(className, (0, _lodash().compact)(members), context.getLocation(node), doc);
143
113
  }
144
114
 
145
115
  }
@@ -1 +1 @@
1
- {"version":3,"names":["ClassDecelerationTransformer","predicate","node","kind","ts","SyntaxKind","ClassDeclaration","getName","name","getText","getIdentifiers","ExportIdentifier","getSourceFile","fileName","transform","context","className","members","pMapSeries","member","isPrivate","modifiers","some","modifier","PrivateKeyword","isSemicolonClassElement","GetAccessor","getter","info","getQuickInfo","displaySig","body","displayString","typeStr","parseTypeFromQuickInfo","type","resolveType","GetAccessorSchema","getLocation","SetAccessor","setter","params","getParams","parameters","getQuickInfoDisplayString","SetAccessorSchema","computeSchema","ClassSchema","compact"],"sources":["class-deceleration.ts"],"sourcesContent":["import pMapSeries from 'p-map-series';\nimport { compact } from 'lodash';\nimport { ClassSchema, GetAccessorSchema, SetAccessorSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, ClassDeclaration, isSemicolonClassElement } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\nimport { getParams } from './utils/get-params';\n\nexport class ClassDecelerationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.ClassDeclaration;\n }\n\n // @todo: in case of `export default class` the class has no name.\n private getName(node: ClassDeclaration) {\n return node.name?.getText() || 'default';\n }\n\n async getIdentifiers(node: ClassDeclaration) {\n return [new ExportIdentifier(this.getName(node), node.getSourceFile().fileName)];\n }\n\n async transform(node: ClassDeclaration, context: SchemaExtractorContext) {\n const className = this.getName(node);\n const members = await pMapSeries(node.members, async (member) => {\n const isPrivate = member.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.PrivateKeyword);\n if (isPrivate) {\n return null;\n }\n if (isSemicolonClassElement(member)) {\n return null;\n }\n switch (member.kind) {\n case ts.SyntaxKind.GetAccessor: {\n const getter = member as ts.GetAccessorDeclaration;\n const info = await context.getQuickInfo(getter.name);\n const displaySig = info?.body?.displayString || '';\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(getter, typeStr);\n return new GetAccessorSchema(context.getLocation(getter), getter.name.getText(), type, displaySig);\n }\n case ts.SyntaxKind.SetAccessor: {\n const setter = member as ts.SetAccessorDeclaration;\n const params = await getParams(setter.parameters, context);\n const displaySig = await context.getQuickInfoDisplayString(setter.name);\n return new SetAccessorSchema(context.getLocation(setter), setter.name.getText(), params[0], displaySig);\n }\n default:\n return context.computeSchema(member);\n }\n });\n return new ClassSchema(className, compact(members), context.getLocation(node));\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;E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AAAgC,iBAAA,EAAQ/B,OAAR,CAA3B,EAA6CF,OAAO,CAACuB,WAAR,CAAoBpC,IAApB,CAA7C,CAAP;EACD;;AA5CoE"}
1
+ {"version":3,"names":["ClassDecelerationTransformer","predicate","node","kind","ts","SyntaxKind","ClassDeclaration","getName","name","getText","getIdentifiers","ExportIdentifier","getSourceFile","fileName","transform","context","className","members","pMapSeries","member","isPrivate","modifiers","some","modifier","PrivateKeyword","classElementToSchema","doc","jsDocToDocSchema","ClassSchema","compact","getLocation"],"sources":["class-deceleration.ts"],"sourcesContent":["import pMapSeries from 'p-map-series';\nimport { compact } from 'lodash';\nimport { ClassSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, ClassDeclaration } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { jsDocToDocSchema } from './utils/jsdoc-to-doc-schema';\nimport { classElementToSchema } from './utils/class-element-to-schema';\n\nexport class ClassDecelerationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.ClassDeclaration;\n }\n\n // @todo: in case of `export default class` the class has no name.\n private getName(node: ClassDeclaration) {\n return node.name?.getText() || 'default';\n }\n\n async getIdentifiers(node: ClassDeclaration) {\n return [new ExportIdentifier(this.getName(node), node.getSourceFile().fileName)];\n }\n\n async transform(node: ClassDeclaration, context: SchemaExtractorContext) {\n const className = this.getName(node);\n const members = await pMapSeries(node.members, async (member) => {\n const isPrivate = member.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.PrivateKeyword);\n if (isPrivate) {\n return null;\n }\n return classElementToSchema(member, context);\n });\n const doc = await jsDocToDocSchema(node, context);\n return new ClassSchema(className, compact(members), context.getLocation(node), doc);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;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zB,IAAjB,EAAuBa,OAAvB,CAAlB;IACA,OAAO,KAAIa,gCAAJ,EAAgBZ,SAAhB,EAA2B,IAAAa,iBAAA,EAAQZ,OAAR,CAA3B,EAA6CF,OAAO,CAACe,WAAR,CAAoB5B,IAApB,CAA7C,EAAwEwB,GAAxE,CAAP;EACD;;AAzBoE"}
@@ -1,16 +1,10 @@
1
1
  export { ExportDeclaration } from './export-declaration';
2
2
  export { FunctionDeclaration } from './function-declaration';
3
- export { MethodDeclaration } from './method-declaration';
4
- export { PropertyDeclaration } from './property-declaration';
5
3
  export { VariableStatementTransformer } from './variable-statement';
6
4
  export { VariableDeclaration } from './variable-declaration';
7
5
  export { SourceFileTransformer } from './source-file-transformer';
8
6
  export { TypeAliasTransformer } from './type-alias';
9
7
  export { ClassDecelerationTransformer } from './class-deceleration';
10
- export { Constructor } from './constructor';
11
- export { PropertySignature } from './property-signature';
12
8
  export { LiteralTypeTransformer } from './literal-type';
13
- export { IndexSignature } from './index-signature';
14
9
  export { InterfaceDeclarationTransformer } from './interface-declaration';
15
- export { MethodSignatureTransformer } from './method-signature';
16
10
  export { EnumDeclarationTransformer } from './enum-declaration';
@@ -9,12 +9,6 @@ Object.defineProperty(exports, "ClassDecelerationTransformer", {
9
9
  return _classDeceleration().ClassDecelerationTransformer;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "Constructor", {
13
- enumerable: true,
14
- get: function () {
15
- return _constructor().Constructor;
16
- }
17
- });
18
12
  Object.defineProperty(exports, "EnumDeclarationTransformer", {
19
13
  enumerable: true,
20
14
  get: function () {
@@ -33,12 +27,6 @@ Object.defineProperty(exports, "FunctionDeclaration", {
33
27
  return _functionDeclaration().FunctionDeclaration;
34
28
  }
35
29
  });
36
- Object.defineProperty(exports, "IndexSignature", {
37
- enumerable: true,
38
- get: function () {
39
- return _indexSignature().IndexSignature;
40
- }
41
- });
42
30
  Object.defineProperty(exports, "InterfaceDeclarationTransformer", {
43
31
  enumerable: true,
44
32
  get: function () {
@@ -51,30 +39,6 @@ Object.defineProperty(exports, "LiteralTypeTransformer", {
51
39
  return _literalType().LiteralTypeTransformer;
52
40
  }
53
41
  });
54
- Object.defineProperty(exports, "MethodDeclaration", {
55
- enumerable: true,
56
- get: function () {
57
- return _methodDeclaration().MethodDeclaration;
58
- }
59
- });
60
- Object.defineProperty(exports, "MethodSignatureTransformer", {
61
- enumerable: true,
62
- get: function () {
63
- return _methodSignature().MethodSignatureTransformer;
64
- }
65
- });
66
- Object.defineProperty(exports, "PropertyDeclaration", {
67
- enumerable: true,
68
- get: function () {
69
- return _propertyDeclaration().PropertyDeclaration;
70
- }
71
- });
72
- Object.defineProperty(exports, "PropertySignature", {
73
- enumerable: true,
74
- get: function () {
75
- return _propertySignature().PropertySignature;
76
- }
77
- });
78
42
  Object.defineProperty(exports, "SourceFileTransformer", {
79
43
  enumerable: true,
80
44
  get: function () {
@@ -120,26 +84,6 @@ function _functionDeclaration() {
120
84
  return data;
121
85
  }
122
86
 
123
- function _methodDeclaration() {
124
- const data = require("./method-declaration");
125
-
126
- _methodDeclaration = function () {
127
- return data;
128
- };
129
-
130
- return data;
131
- }
132
-
133
- function _propertyDeclaration() {
134
- const data = require("./property-declaration");
135
-
136
- _propertyDeclaration = function () {
137
- return data;
138
- };
139
-
140
- return data;
141
- }
142
-
143
87
  function _variableStatement() {
144
88
  const data = require("./variable-statement");
145
89
 
@@ -190,26 +134,6 @@ function _classDeceleration() {
190
134
  return data;
191
135
  }
192
136
 
193
- function _constructor() {
194
- const data = require("./constructor");
195
-
196
- _constructor = function () {
197
- return data;
198
- };
199
-
200
- return data;
201
- }
202
-
203
- function _propertySignature() {
204
- const data = require("./property-signature");
205
-
206
- _propertySignature = function () {
207
- return data;
208
- };
209
-
210
- return data;
211
- }
212
-
213
137
  function _literalType() {
214
138
  const data = require("./literal-type");
215
139
 
@@ -220,16 +144,6 @@ function _literalType() {
220
144
  return data;
221
145
  }
222
146
 
223
- function _indexSignature() {
224
- const data = require("./index-signature");
225
-
226
- _indexSignature = function () {
227
- return data;
228
- };
229
-
230
- return data;
231
- }
232
-
233
147
  function _interfaceDeclaration() {
234
148
  const data = require("./interface-declaration");
235
149
 
@@ -240,16 +154,6 @@ function _interfaceDeclaration() {
240
154
  return data;
241
155
  }
242
156
 
243
- function _methodSignature() {
244
- const data = require("./method-signature");
245
-
246
- _methodSignature = function () {
247
- return data;
248
- };
249
-
250
- return data;
251
- }
252
-
253
157
  function _enumDeclaration() {
254
158
  const data = require("./enum-declaration");
255
159
 
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { ExportDeclaration } from './export-declaration';\nexport { FunctionDeclaration } from './function-declaration';\nexport { MethodDeclaration } from './method-declaration';\nexport { PropertyDeclaration } from './property-declaration';\nexport { VariableStatementTransformer } from './variable-statement';\nexport { VariableDeclaration } from './variable-declaration';\nexport { SourceFileTransformer } from './source-file-transformer';\nexport { TypeAliasTransformer } from './type-alias';\nexport { ClassDecelerationTransformer } from './class-deceleration';\nexport { Constructor } from './constructor';\nexport { PropertySignature } from './property-signature';\nexport { LiteralTypeTransformer } from './literal-type';\nexport { IndexSignature } from './index-signature';\nexport { InterfaceDeclarationTransformer } from './interface-declaration';\nexport { MethodSignatureTransformer } from './method-signature';\nexport { EnumDeclarationTransformer } from './enum-declaration';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { ExportDeclaration } from './export-declaration';\nexport { FunctionDeclaration } from './function-declaration';\nexport { VariableStatementTransformer } from './variable-statement';\nexport { VariableDeclaration } from './variable-declaration';\nexport { SourceFileTransformer } from './source-file-transformer';\nexport { TypeAliasTransformer } from './type-alias';\nexport { ClassDecelerationTransformer } from './class-deceleration';\nexport { LiteralTypeTransformer } from './literal-type';\nexport { InterfaceDeclarationTransformer } from './interface-declaration';\nexport { EnumDeclarationTransformer } from './enum-declaration';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA"}
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", {
10
10
  exports.InterfaceDeclarationTransformer = void 0;
11
11
 
12
12
  function _typescript() {
13
- const data = _interopRequireDefault(require("typescript"));
13
+ const data = require("typescript");
14
14
 
15
15
  _typescript = function () {
16
16
  return data;
@@ -49,9 +49,19 @@ function _exportIdentifier() {
49
49
  return data;
50
50
  }
51
51
 
52
+ function _typeElementToSchema() {
53
+ const data = require("./utils/type-element-to-schema");
54
+
55
+ _typeElementToSchema = function () {
56
+ return data;
57
+ };
58
+
59
+ return data;
60
+ }
61
+
52
62
  class InterfaceDeclarationTransformer {
53
63
  predicate(node) {
54
- return node.kind === _typescript().default.SyntaxKind.InterfaceDeclaration;
64
+ return node.kind === _typescript().SyntaxKind.InterfaceDeclaration;
55
65
  }
56
66
 
57
67
  async getIdentifiers(node) {
@@ -59,10 +69,7 @@ class InterfaceDeclarationTransformer {
59
69
  }
60
70
 
61
71
  async transform(interfaceDec, context) {
62
- const members = await (0, _pMapSeries().default)(interfaceDec.members, async member => {
63
- const typeSchema = await context.computeSchema(member);
64
- return typeSchema;
65
- });
72
+ const members = await (0, _pMapSeries().default)(interfaceDec.members, member => (0, _typeElementToSchema().typeElementToSchema)(member, context));
66
73
  return new (_semanticsEntities().InterfaceSchema)(context.getLocation(interfaceDec), interfaceDec.name.getText(), members);
67
74
  }
68
75
 
@@ -1 +1 @@
1
- {"version":3,"names":["InterfaceDeclarationTransformer","predicate","node","kind","ts","SyntaxKind","InterfaceDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","transform","interfaceDec","context","members","pMapSeries","member","typeSchema","computeSchema","InterfaceSchema","getLocation"],"sources":["interface-declaration.ts"],"sourcesContent":["import ts, { Node, InterfaceDeclaration } from 'typescript';\nimport pMapSeries from 'p-map-series';\nimport { InterfaceSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\n\nexport class InterfaceDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.InterfaceDeclaration;\n }\n\n async getIdentifiers(node: InterfaceDeclaration): Promise<ExportIdentifier[]> {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(interfaceDec: InterfaceDeclaration, context: SchemaExtractorContext) {\n const members = await pMapSeries(interfaceDec.members, async (member) => {\n const typeSchema = await context.computeSchema(member);\n return typeSchema;\n });\n return new InterfaceSchema(context.getLocation(interfaceDec), interfaceDec.name.getText(), members);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,+BAAN,CAAmE;EACxEC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcC,oBAAnC;EACD;;EAEmB,MAAdC,cAAc,CAACL,IAAD,EAA0D;IAC5E,OAAO,CAAC,KAAIM,oCAAJ,EAAqBN,IAAI,CAACO,IAAL,CAAUC,OAAV,EAArB,EAA0CR,IAAI,CAACS,aAAL,GAAqBC,QAA/D,CAAD,CAAP;EACD;;EAEc,MAATC,SAAS,CAACC,YAAD,EAAqCC,OAArC,EAAsE;IACnF,MAAMC,OAAO,GAAG,MAAM,IAAAC,qBAAA,EAAWH,YAAY,CAACE,OAAxB,EAAiC,MAAOE,MAAP,IAAkB;MACvE,MAAMC,UAAU,GAAG,MAAMJ,OAAO,CAACK,aAAR,CAAsBF,MAAtB,CAAzB;MACA,OAAOC,UAAP;IACD,CAHqB,CAAtB;IAIA,OAAO,KAAIE,oCAAJ,EAAoBN,OAAO,CAACO,WAAR,CAAoBR,YAApB,CAApB,EAAuDA,YAAY,CAACL,IAAb,CAAkBC,OAAlB,EAAvD,EAAoFM,OAApF,CAAP;EACD;;AAfuE"}
1
+ {"version":3,"names":["InterfaceDeclarationTransformer","predicate","node","kind","SyntaxKind","InterfaceDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","transform","interfaceDec","context","members","pMapSeries","member","typeElementToSchema","InterfaceSchema","getLocation"],"sources":["interface-declaration.ts"],"sourcesContent":["import { Node, InterfaceDeclaration, SyntaxKind } from 'typescript';\nimport pMapSeries from 'p-map-series';\nimport { InterfaceSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { typeElementToSchema } from './utils/type-element-to-schema';\n\nexport class InterfaceDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.InterfaceDeclaration;\n }\n\n async getIdentifiers(node: InterfaceDeclaration): Promise<ExportIdentifier[]> {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(interfaceDec: InterfaceDeclaration, context: SchemaExtractorContext) {\n const members = await pMapSeries(interfaceDec.members, (member) => typeElementToSchema(member, context));\n return new InterfaceSchema(context.getLocation(interfaceDec), interfaceDec.name.getText(), members);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,+BAAN,CAAmE;EACxEC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,wBAAA,CAAWC,oBAAhC;EACD;;EAEmB,MAAdC,cAAc,CAACJ,IAAD,EAA0D;IAC5E,OAAO,CAAC,KAAIK,oCAAJ,EAAqBL,IAAI,CAACM,IAAL,CAAUC,OAAV,EAArB,EAA0CP,IAAI,CAACQ,aAAL,GAAqBC,QAA/D,CAAD,CAAP;EACD;;EAEc,MAATC,SAAS,CAACC,YAAD,EAAqCC,OAArC,EAAsE;IACnF,MAAMC,OAAO,GAAG,MAAM,IAAAC,qBAAA,EAAWH,YAAY,CAACE,OAAxB,EAAkCE,MAAD,IAAY,IAAAC,0CAAA,EAAoBD,MAApB,EAA4BH,OAA5B,CAA7C,CAAtB;IACA,OAAO,KAAIK,oCAAJ,EAAoBL,OAAO,CAACM,WAAR,CAAoBP,YAApB,CAApB,EAAuDA,YAAY,CAACL,IAAb,CAAkBC,OAAlB,EAAvD,EAAoFM,OAApF,CAAP;EACD;;AAZuE"}
@@ -0,0 +1,4 @@
1
+ import { ClassElement } from 'typescript';
2
+ import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';
3
+ import { SchemaExtractorContext } from '../../schema-extractor-context';
4
+ export declare function classElementToSchema(node: ClassElement, context: SchemaExtractorContext): Promise<SchemaNode | null>;
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.promise.js");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.classElementToSchema = classElementToSchema;
9
+
10
+ function _typescript() {
11
+ const data = require("typescript");
12
+
13
+ _typescript = function () {
14
+ return data;
15
+ };
16
+
17
+ return data;
18
+ }
19
+
20
+ function _semanticsEntities() {
21
+ const data = require("@teambit/semantics.entities.semantic-schema");
22
+
23
+ _semanticsEntities = function () {
24
+ return data;
25
+ };
26
+
27
+ return data;
28
+ }
29
+
30
+ function _getParams() {
31
+ const data = require("./get-params");
32
+
33
+ _getParams = function () {
34
+ return data;
35
+ };
36
+
37
+ return data;
38
+ }
39
+
40
+ function _typeElementToSchema() {
41
+ const data = require("./type-element-to-schema");
42
+
43
+ _typeElementToSchema = function () {
44
+ return data;
45
+ };
46
+
47
+ return data;
48
+ }
49
+
50
+ function _parseTypeFromQuickInfo() {
51
+ const data = require("./parse-type-from-quick-info");
52
+
53
+ _parseTypeFromQuickInfo = function () {
54
+ return data;
55
+ };
56
+
57
+ return data;
58
+ }
59
+
60
+ function _toFunctionSchema() {
61
+ const data = require("./to-function-schema");
62
+
63
+ _toFunctionSchema = function () {
64
+ return data;
65
+ };
66
+
67
+ return data;
68
+ }
69
+
70
+ async function classElementToSchema(node, context) {
71
+ switch (node.kind) {
72
+ case _typescript().SyntaxKind.Constructor:
73
+ return constructor(node, context);
74
+
75
+ case _typescript().SyntaxKind.PropertyDeclaration:
76
+ return propertyDeclaration(node, context);
77
+
78
+ case _typescript().SyntaxKind.MethodDeclaration:
79
+ return methodDeclaration(node, context);
80
+
81
+ case _typescript().SyntaxKind.GetAccessor:
82
+ return (0, _typeElementToSchema().getAccessor)(node, context);
83
+
84
+ case _typescript().SyntaxKind.SetAccessor:
85
+ return (0, _typeElementToSchema().setAccessor)(node, context);
86
+
87
+ case _typescript().SyntaxKind.IndexSignature:
88
+ return (0, _typeElementToSchema().indexSignature)(node, context);
89
+
90
+ case _typescript().SyntaxKind.ClassStaticBlockDeclaration: // not sure what is it, but the name sounds like not something we need
91
+
92
+ case _typescript().SyntaxKind.SemicolonClassElement:
93
+ // seems to be just a semicolon
94
+ return null;
95
+
96
+ default:
97
+ // should never be here unless typescript added new class elements
98
+ throw new Error(`unrecognized ClassElement type. got ${node.kind}`);
99
+ }
100
+ }
101
+
102
+ async function constructor(node, context) {
103
+ const args = await (0, _getParams().getParams)(node.parameters, context);
104
+ return new (_semanticsEntities().ConstructorSchema)(context.getLocation(node), args);
105
+ }
106
+
107
+ async function propertyDeclaration(node, context) {
108
+ var _info$body;
109
+
110
+ const name = node.name.getText();
111
+ const info = await context.getQuickInfo(node.name);
112
+ const displaySig = info === null || info === void 0 ? void 0 : (_info$body = info.body) === null || _info$body === void 0 ? void 0 : _info$body.displayString;
113
+ const typeStr = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
114
+ const type = await context.resolveType(node, typeStr);
115
+ return new (_semanticsEntities().VariableSchema)(context.getLocation(node), name, displaySig || '', type);
116
+ }
117
+
118
+ async function methodDeclaration(node, context) {
119
+ return (0, _toFunctionSchema().toFunctionLikeSchema)(node, context);
120
+ }
121
+
122
+ //# sourceMappingURL=class-element-to-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["classElementToSchema","node","context","kind","SyntaxKind","Constructor","constructor","PropertyDeclaration","propertyDeclaration","MethodDeclaration","methodDeclaration","GetAccessor","getAccessor","SetAccessor","setAccessor","IndexSignature","indexSignature","ClassStaticBlockDeclaration","SemicolonClassElement","Error","args","getParams","parameters","ConstructorSchema","getLocation","name","getText","info","getQuickInfo","displaySig","body","displayString","typeStr","parseTypeFromQuickInfo","type","resolveType","VariableSchema","toFunctionLikeSchema"],"sources":["class-element-to-schema.ts"],"sourcesContent":["import {\n ClassElement,\n ConstructorDeclaration,\n GetAccessorDeclaration,\n IndexSignatureDeclaration,\n MethodDeclaration,\n PropertyDeclaration,\n SetAccessorDeclaration,\n SyntaxKind,\n} from 'typescript';\nimport { ConstructorSchema, SchemaNode, VariableSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { getParams } from './get-params';\nimport { getAccessor, indexSignature, setAccessor } from './type-element-to-schema';\nimport { parseTypeFromQuickInfo } from './parse-type-from-quick-info';\nimport { toFunctionLikeSchema } from './to-function-schema';\n\nexport async function classElementToSchema(\n node: ClassElement,\n context: SchemaExtractorContext\n): Promise<SchemaNode | null> {\n switch (node.kind) {\n case SyntaxKind.Constructor:\n return constructor(node as ConstructorDeclaration, context);\n case SyntaxKind.PropertyDeclaration:\n return propertyDeclaration(node as PropertyDeclaration, context);\n case SyntaxKind.MethodDeclaration:\n return methodDeclaration(node as MethodDeclaration, context);\n case SyntaxKind.GetAccessor:\n return getAccessor(node as GetAccessorDeclaration, context);\n case SyntaxKind.SetAccessor:\n return setAccessor(node as SetAccessorDeclaration, context);\n case SyntaxKind.IndexSignature:\n return indexSignature(node as IndexSignatureDeclaration, context);\n case SyntaxKind.ClassStaticBlockDeclaration: // not sure what is it, but the name sounds like not something we need\n case SyntaxKind.SemicolonClassElement: // seems to be just a semicolon\n return null;\n default:\n // should never be here unless typescript added new class elements\n throw new Error(`unrecognized ClassElement type. got ${node.kind}`);\n }\n}\n\nasync function constructor(node: ConstructorDeclaration, context: SchemaExtractorContext) {\n const args = await getParams(node.parameters, context);\n return new ConstructorSchema(context.getLocation(node), args);\n}\n\nasync function propertyDeclaration(node: PropertyDeclaration, context: SchemaExtractorContext) {\n const name = node.name.getText();\n const info = await context.getQuickInfo(node.name);\n const displaySig = info?.body?.displayString;\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(node, typeStr);\n\n return new VariableSchema(context.getLocation(node), name, displaySig || '', type);\n}\n\nasync function methodDeclaration(node: MethodDeclaration, context: SchemaExtractorContext) {\n return toFunctionLikeSchema(node, context);\n}\n"],"mappings":";;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAUA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,eAAeA,oBAAf,CACLC,IADK,EAELC,OAFK,EAGuB;EAC5B,QAAQD,IAAI,CAACE,IAAb;IACE,KAAKC,wBAAA,CAAWC,WAAhB;MACE,OAAOC,WAAW,CAACL,IAAD,EAAiCC,OAAjC,CAAl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CAAEG,IAAT,+CAAG,WAAYC,aAA/B;EACA,MAAMC,OAAO,GAAG,IAAAC,gDAAA,EAAuBN,IAAvB,CAAhB;EACA,MAAMO,IAAI,GAAG,MAAMhC,OAAO,CAACiC,WAAR,CAAoBlC,IAApB,EAA0B+B,OAA1B,CAAnB;EAEA,OAAO,KAAII,mCAAJ,EAAmBlC,OAAO,CAACsB,WAAR,CAAoBvB,IAApB,CAAnB,EAA8CwB,IAA9C,EAAoDI,UAAU,IAAI,EAAlE,EAAsEK,IAAtE,CAAP;AACD;;AAED,eAAexB,iBAAf,CAAiCT,IAAjC,EAA0DC,OAA1D,EAA2F;EACzF,OAAO,IAAAmC,wCAAA,EAAqBpC,IAArB,EAA2BC,OAA3B,CAAP;AACD"}
@@ -0,0 +1,4 @@
1
+ import { Node } from 'typescript';
2
+ import { DocSchema } from '@teambit/semantics.entities.semantic-schema';
3
+ import { SchemaExtractorContext } from '../../schema-extractor-context';
4
+ export declare function jsDocToDocSchema(node: Node, context: SchemaExtractorContext): Promise<DocSchema | undefined>;
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ require("core-js/modules/es.promise.js");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.jsDocToDocSchema = jsDocToDocSchema;
11
+
12
+ function _typescript() {
13
+ const data = require("typescript");
14
+
15
+ _typescript = function () {
16
+ return data;
17
+ };
18
+
19
+ return data;
20
+ }
21
+
22
+ function _tsutils() {
23
+ const data = require("tsutils");
24
+
25
+ _tsutils = function () {
26
+ return data;
27
+ };
28
+
29
+ return data;
30
+ }
31
+
32
+ function _pMapSeries() {
33
+ const data = _interopRequireDefault(require("p-map-series"));
34
+
35
+ _pMapSeries = function () {
36
+ return data;
37
+ };
38
+
39
+ return data;
40
+ }
41
+
42
+ function _semanticsEntities() {
43
+ const data = require("@teambit/semantics.entities.semantic-schema");
44
+
45
+ _semanticsEntities = function () {
46
+ return data;
47
+ };
48
+
49
+ return data;
50
+ }
51
+
52
+ function _typeNodeToSchema() {
53
+ const data = require("./type-node-to-schema");
54
+
55
+ _typeNodeToSchema = function () {
56
+ return data;
57
+ };
58
+
59
+ return data;
60
+ }
61
+
62
+ /* eslint-disable no-fallthrough */
63
+ async function jsDocToDocSchema(node, context) {
64
+ if (!(0, _tsutils().canHaveJsDoc)(node)) {
65
+ return undefined;
66
+ }
67
+
68
+ const jsDocs = (0, _tsutils().getJsDoc)(node);
69
+
70
+ if (!jsDocs.length) {
71
+ return undefined;
72
+ } // not sure how common it is to have multiple JSDocs. never seen it before.
73
+ // regardless, in typescript implementation of methods like `getJSDocDeprecatedTag()`, they use the first one. (`getFirstJSDocTag()`)
74
+
75
+
76
+ const jsDoc = jsDocs[0];
77
+ const location = context.getLocation(jsDoc);
78
+ const comment = (0, _typescript().getTextOfJSDocComment)(jsDoc.comment);
79
+ const tags = jsDoc.tags ? await (0, _pMapSeries().default)(jsDoc.tags, tag => tagParser(tag, context)) : undefined;
80
+ return new (_semanticsEntities().DocSchema)(location, comment, tags);
81
+ }
82
+
83
+ async function tagParser(tag, context) {
84
+ let tagName = tag.tagName.getText();
85
+
86
+ switch (tag.kind) {
87
+ case _typescript().SyntaxKind.JSDocReturnTag:
88
+ return returnTag(tag, context);
89
+
90
+ case _typescript().SyntaxKind.JSDocAugmentsTag:
91
+ tagName = _semanticsEntities().TagName.augments;
92
+
93
+ case _typescript().SyntaxKind.JSDocAuthorTag:
94
+ tagName = _semanticsEntities().TagName.author;
95
+
96
+ case _typescript().SyntaxKind.JSDocClassTag:
97
+ tagName = _semanticsEntities().TagName.class;
98
+
99
+ case _typescript().SyntaxKind.JSDocCallbackTag:
100
+ tagName = _semanticsEntities().TagName.callback;
101
+
102
+ case _typescript().SyntaxKind.JSDocPublicTag:
103
+ tagName = _semanticsEntities().TagName.public;
104
+
105
+ case _typescript().SyntaxKind.JSDocPrivateTag:
106
+ tagName = _semanticsEntities().TagName.private;
107
+
108
+ case _typescript().SyntaxKind.JSDocProtectedTag:
109
+ tagName = _semanticsEntities().TagName.protected;
110
+
111
+ case _typescript().SyntaxKind.JSDocReadonlyTag:
112
+ tagName = _semanticsEntities().TagName.readonly;
113
+
114
+ case _typescript().SyntaxKind.JSDocOverrideTag:
115
+ tagName = _semanticsEntities().TagName.override;
116
+
117
+ case _typescript().SyntaxKind.JSDocDeprecatedTag:
118
+ tagName = _semanticsEntities().TagName.deprecated;
119
+
120
+ case _typescript().SyntaxKind.JSDocSeeTag:
121
+ tagName = _semanticsEntities().TagName.see;
122
+
123
+ case _typescript().SyntaxKind.JSDocEnumTag:
124
+ tagName = _semanticsEntities().TagName.enum;
125
+
126
+ case _typescript().SyntaxKind.JSDocParameterTag:
127
+ tagName = _semanticsEntities().TagName.parameter;
128
+
129
+ case _typescript().SyntaxKind.JSDocThisTag:
130
+ tagName = _semanticsEntities().TagName.this;
131
+
132
+ case _typescript().SyntaxKind.JSDocTypeTag:
133
+ tagName = _semanticsEntities().TagName.type;
134
+
135
+ case _typescript().SyntaxKind.JSDocTemplateTag:
136
+ tagName = _semanticsEntities().TagName.template;
137
+
138
+ case _typescript().SyntaxKind.JSDocTypedefTag:
139
+ tagName = _semanticsEntities().TagName.typedef;
140
+
141
+ case _typescript().SyntaxKind.JSDocPropertyTag:
142
+ tagName = _semanticsEntities().TagName.property;
143
+
144
+ case _typescript().SyntaxKind.JSDocImplementsTag:
145
+ tagName = _semanticsEntities().TagName.implements;
146
+
147
+ default:
148
+ return simpleTag(tag, tagName, context);
149
+ }
150
+ }
151
+
152
+ function simpleTag(tag, tagName, context) {
153
+ return new (_semanticsEntities().TagSchema)(context.getLocation(tag), tagName, (0, _typescript().getTextOfJSDocComment)(tag.comment));
154
+ }
155
+
156
+ async function returnTag(tag, context) {
157
+ var _tag$typeExpression, _tag$typeExpression2;
158
+
159
+ const type = (_tag$typeExpression = tag.typeExpression) !== null && _tag$typeExpression !== void 0 && _tag$typeExpression.type ? await (0, _typeNodeToSchema().typeNodeToSchema)((_tag$typeExpression2 = tag.typeExpression) === null || _tag$typeExpression2 === void 0 ? void 0 : _tag$typeExpression2.type, context) : undefined;
160
+ return new (_semanticsEntities().ReturnTagSchema)(context.getLocation(tag), _semanticsEntities().TagName.return, (0, _typescript().getTextOfJSDocComment)(tag.comment), type);
161
+ }
162
+
163
+ //# sourceMappingURL=jsdoc-to-doc-schema.js.map