@teambit/typescript 0.0.894 → 0.0.895

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 (68) hide show
  1. package/dist/schema-extractor-context.d.ts +6 -3
  2. package/dist/schema-extractor-context.js +41 -10
  3. package/dist/schema-extractor-context.js.map +1 -1
  4. package/dist/transformers/binding-element.js +1 -8
  5. package/dist/transformers/binding-element.js.map +1 -1
  6. package/dist/transformers/{class-deceleration.d.ts → class-declaration.d.ts} +2 -1
  7. package/dist/transformers/class-declaration.js +130 -0
  8. package/dist/transformers/class-declaration.js.map +1 -0
  9. package/dist/transformers/enum-declaration.js +20 -2
  10. package/dist/transformers/enum-declaration.js.map +1 -1
  11. package/dist/transformers/export-declaration.js +2 -2
  12. package/dist/transformers/export-declaration.js.map +1 -1
  13. package/dist/transformers/index.d.ts +1 -1
  14. package/dist/transformers/index.js +5 -5
  15. package/dist/transformers/index.js.map +1 -1
  16. package/dist/transformers/interface-declaration.d.ts +1 -0
  17. package/dist/transformers/interface-declaration.js +47 -5
  18. package/dist/transformers/interface-declaration.js.map +1 -1
  19. package/dist/transformers/source-file-transformer.d.ts +2 -2
  20. package/dist/transformers/source-file-transformer.js +1 -1
  21. package/dist/transformers/source-file-transformer.js.map +1 -1
  22. package/dist/transformers/type-alias.js +1 -8
  23. package/dist/transformers/type-alias.js.map +1 -1
  24. package/dist/transformers/utils/class-element-to-schema.js +7 -11
  25. package/dist/transformers/utils/class-element-to-schema.js.map +1 -1
  26. package/dist/transformers/utils/jsdoc-to-doc-schema.d.ts +4 -3
  27. package/dist/transformers/utils/jsdoc-to-doc-schema.js +11 -33
  28. package/dist/transformers/utils/jsdoc-to-doc-schema.js.map +1 -1
  29. package/dist/transformers/utils/parse-type-from-quick-info.js +4 -0
  30. package/dist/transformers/utils/parse-type-from-quick-info.js.map +1 -1
  31. package/dist/transformers/utils/to-function-like-schema.js +1 -8
  32. package/dist/transformers/utils/to-function-like-schema.js.map +1 -1
  33. package/dist/transformers/utils/type-element-to-schema.js +1 -8
  34. package/dist/transformers/utils/type-element-to-schema.js.map +1 -1
  35. package/dist/transformers/utils/type-node-to-schema.js +9 -9
  36. package/dist/transformers/utils/type-node-to-schema.js.map +1 -1
  37. package/dist/transformers/variable-declaration.js +13 -11
  38. package/dist/transformers/variable-declaration.js.map +1 -1
  39. package/dist/transformers/variable-statement.js +1 -1
  40. package/dist/transformers/variable-statement.js.map +1 -1
  41. package/dist/typescript.extractor.d.ts +2 -1
  42. package/dist/typescript.extractor.js +4 -4
  43. package/dist/typescript.extractor.js.map +1 -1
  44. package/dist/typescript.main.runtime.js +4 -4
  45. package/dist/typescript.main.runtime.js.map +1 -1
  46. package/package-tar/teambit-typescript-0.0.895.tgz +0 -0
  47. package/package.json +15 -14
  48. package/{preview-1667878820252.js → preview-1667965305919.js} +2 -2
  49. package/transformers/binding-element.ts +1 -2
  50. package/transformers/class-declaration.ts +97 -0
  51. package/transformers/enum-declaration.ts +14 -3
  52. package/transformers/export-declaration.ts +3 -3
  53. package/transformers/index.ts +1 -1
  54. package/transformers/interface-declaration.ts +49 -5
  55. package/transformers/source-file-transformer.ts +2 -2
  56. package/transformers/type-alias.ts +1 -2
  57. package/transformers/utils/class-element-to-schema.ts +4 -3
  58. package/transformers/utils/jsdoc-to-doc-schema.ts +15 -22
  59. package/transformers/utils/parse-type-from-quick-info.ts +3 -0
  60. package/transformers/utils/to-function-like-schema.ts +2 -2
  61. package/transformers/utils/type-element-to-schema.ts +1 -2
  62. package/transformers/utils/type-node-to-schema.ts +12 -3
  63. package/transformers/variable-declaration.ts +21 -3
  64. package/transformers/variable-statement.ts +2 -2
  65. package/dist/transformers/class-deceleration.js +0 -87
  66. package/dist/transformers/class-deceleration.js.map +0 -1
  67. package/package-tar/teambit-typescript-0.0.894.tgz +0 -0
  68. package/transformers/class-deceleration.ts +0 -37
@@ -3,8 +3,9 @@ import ts, { ExportAssignment, ExportDeclaration, Node, TypeNode } from 'typescr
3
3
  import protocol from 'typescript/lib/protocol';
4
4
  import type { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';
5
5
  import { Component } from '@teambit/component';
6
- import { TypeRefSchema, SchemaNode, Location } from '@teambit/semantics.entities.semantic-schema';
6
+ import { TypeRefSchema, SchemaNode, Location, DocSchema } from '@teambit/semantics.entities.semantic-schema';
7
7
  import { ComponentDependency } from '@teambit/dependency-resolver';
8
+ import { Formatter } from '@teambit/formatter';
8
9
  import { TypeScriptExtractor } from './typescript.extractor';
9
10
  import { ExportList } from './export-list';
10
11
  export declare class SchemaExtractorContext {
@@ -12,7 +13,8 @@ export declare class SchemaExtractorContext {
12
13
  readonly component: Component;
13
14
  readonly extractor: TypeScriptExtractor;
14
15
  readonly componentDeps: ComponentDependency[];
15
- constructor(tsserver: TsserverClient, component: Component, extractor: TypeScriptExtractor, componentDeps: ComponentDependency[]);
16
+ readonly formatter: Formatter;
17
+ constructor(tsserver: TsserverClient, component: Component, extractor: TypeScriptExtractor, componentDeps: ComponentDependency[], formatter: Formatter);
16
18
  computeSchema(node: Node): Promise<SchemaNode>;
17
19
  /**
18
20
  * returns the location of a node in a source file.
@@ -52,7 +54,7 @@ export declare class SchemaExtractorContext {
52
54
  /**
53
55
  * get a definition for a given node.
54
56
  */
55
- definition(definitonInfo: protocol.DefinitionInfo): Promise<Node | undefined>;
57
+ definition(definition: protocol.DefinitionInfo): Promise<Node | undefined>;
56
58
  /**
57
59
  * visit a definition for node - e.g. return it's schema.
58
60
  */
@@ -75,4 +77,5 @@ export declare class SchemaExtractorContext {
75
77
  private getCompIdByPkgName;
76
78
  getTypeRefForExternalNode(node: Node): Promise<TypeRefSchema>;
77
79
  getTypeRefForExternalPath(typeStr: string, filePath: string, location: Location): Promise<TypeRefSchema>;
80
+ jsDocToDocSchema(node: Node): Promise<DocSchema | undefined>;
78
81
  }
@@ -15,16 +15,16 @@ function _defineProperty2() {
15
15
  };
16
16
  return data;
17
17
  }
18
- function _typescript() {
19
- const data = _interopRequireWildcard(require("typescript"));
20
- _typescript = function () {
18
+ function _tsutils() {
19
+ const data = require("tsutils");
20
+ _tsutils = function () {
21
21
  return data;
22
22
  };
23
23
  return data;
24
24
  }
25
- function _tsutils() {
26
- const data = require("tsutils");
27
- _tsutils = function () {
25
+ function _typescript() {
26
+ const data = _interopRequireWildcard(require("typescript"));
27
+ _typescript = function () {
28
28
  return data;
29
29
  };
30
30
  return data;
@@ -57,6 +57,13 @@ function _semanticsEntities() {
57
57
  };
58
58
  return data;
59
59
  }
60
+ function _pMapSeries() {
61
+ const data = _interopRequireDefault(require("p-map-series"));
62
+ _pMapSeries = function () {
63
+ return data;
64
+ };
65
+ return data;
66
+ }
60
67
  function _typeNodeToSchema() {
61
68
  const data = require("./transformers/utils/type-node-to-schema");
62
69
  _typeNodeToSchema = function () {
@@ -78,14 +85,22 @@ function _parseTypeFromQuickInfo() {
78
85
  };
79
86
  return data;
80
87
  }
88
+ function _jsdocToDocSchema() {
89
+ const data = require("./transformers/utils/jsdoc-to-doc-schema");
90
+ _jsdocToDocSchema = function () {
91
+ return data;
92
+ };
93
+ return data;
94
+ }
81
95
  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); }
82
96
  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; }
83
97
  class SchemaExtractorContext {
84
- constructor(tsserver, component, extractor, componentDeps) {
98
+ constructor(tsserver, component, extractor, componentDeps, formatter) {
85
99
  this.tsserver = tsserver;
86
100
  this.component = component;
87
101
  this.extractor = extractor;
88
102
  this.componentDeps = componentDeps;
103
+ this.formatter = formatter;
89
104
  (0, _defineProperty2().default)(this, "_exports", undefined);
90
105
  }
91
106
  computeSchema(node) {
@@ -223,9 +238,9 @@ class SchemaExtractorContext {
223
238
  /**
224
239
  * get a definition for a given node.
225
240
  */
226
- async definition(definitonInfo) {
227
- const startPosition = definitonInfo.start;
228
- const sourceFile = this.getSourceFileInsideComponent(definitonInfo.file);
241
+ async definition(definition) {
242
+ const startPosition = definition.start;
243
+ const sourceFile = this.getSourceFileInsideComponent(definition.file);
229
244
  if (!sourceFile) {
230
245
  // it might be an external reference, cant get the node
231
246
  return undefined;
@@ -384,6 +399,22 @@ class SchemaExtractorContext {
384
399
  }
385
400
  return new (_semanticsEntities().TypeRefSchema)(location, typeStr, undefined, pkgName);
386
401
  }
402
+ async jsDocToDocSchema(node) {
403
+ if (!(0, _tsutils().canHaveJsDoc)(node)) {
404
+ return undefined;
405
+ }
406
+ const jsDocs = (0, _tsutils().getJsDoc)(node);
407
+ if (!jsDocs.length) {
408
+ return undefined;
409
+ }
410
+ // not sure how common it is to have multiple JSDocs. never seen it before.
411
+ // regardless, in typescript implementation of methods like `getJSDocDeprecatedTag()`, they use the first one. (`getFirstJSDocTag()`)
412
+ const jsDoc = jsDocs[0];
413
+ const location = this.getLocation(jsDoc);
414
+ const comment = (0, _typescript().getTextOfJSDocComment)(jsDoc.comment);
415
+ const tags = jsDoc.tags ? await (0, _pMapSeries().default)(jsDoc.tags, tag => (0, _jsdocToDocSchema().tagParser)(tag, this, this.formatter)) : undefined;
416
+ return new (_semanticsEntities().DocSchema)(location, jsDoc.getText(), comment, tags);
417
+ }
387
418
  }
388
419
  exports.SchemaExtractorContext = SchemaExtractorContext;
389
420
 
@@ -1 +1 @@
1
- {"version":3,"names":["SchemaExtractorContext","constructor","tsserver","component","extractor","componentDeps","undefined","computeSchema","node","getLocation","targetSourceFile","absolutePath","sourceFile","getSourceFile","position","getLineAndCharacterOfPosition","getStart","line","character","filePath","fileName","getPathRelativeToComponent","pathNormalizeToLinux","getLocationAsString","location","basePath","filesystem","files","base","relative","getSignature","getSignatureHelp","getPath","getPosition","offset","getPositionOfLineAndCharacter","getQuickInfo","err","message","Error","getQuickInfoDisplayString","quickInfo","body","displayString","typeDefinition","getTypeDefinition","visitTypeDefinition","findFileInComponent","find","file","path","includes","strings","map","format","endsWith","string","parsePackageNameFromPath","parts","split","length","lastPart","replace","sep","pkgParts","startsWith","pkgName","getSourceFileInsideComponent","parseSourceFile","getSourceFileFromNode","getFilePathByNode","def","getDefinition","firstDef","head","definitionInfo","definition","definitonInfo","startPosition","start","pos","nodeAtPos","getTokenAtPosition","visitDefinition","getTypeRefForExternalNode","visit","parent","references","isExported","isFromComponent","getFileExports","exportDec","specifierPathStr","kind","SyntaxKind","ExportDeclaration","moduleSpecifier","getText","specifierPath","substring","absPath","resolve","computeExportedIdentifiers","setExports","exports","_exports","getExportedIdentifiers","jump","TransformerNotFound","resolveType","typeStr","isTypeStrFromQuickInfo","TypeRefSchema","type","ts","isTypeNode","typeNodeToSchema","getDef","headTypeDefinition","unknownExactType","InferenceTypeSchema","info","parseTypeFromQuickInfo","isDefInSameLocation","loc","schemaNode","getTypeRefForExternalPath","getCompIdByPkgName","dep","packageName","componentId","compIdByPath","getComponentIDByPath","compIdByPkg"],"sources":["schema-extractor-context.ts"],"sourcesContent":["import { TsserverClient } from '@teambit/ts-server';\nimport ts, { ExportAssignment, ExportDeclaration, Node, SyntaxKind, TypeNode } from 'typescript';\nimport { getTokenAtPosition } from 'tsutils';\nimport { head } from 'lodash';\n// eslint-disable-next-line import/no-unresolved\nimport protocol from 'typescript/lib/protocol';\n// @ts-ignore david we should figure fix this.\nimport type { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport { resolve, sep, relative } from 'path';\nimport { Component, ComponentID } from '@teambit/component';\nimport { TypeRefSchema, SchemaNode, InferenceTypeSchema, Location } from '@teambit/semantics.entities.semantic-schema';\nimport { ComponentDependency } from '@teambit/dependency-resolver';\nimport { TypeScriptExtractor } from './typescript.extractor';\nimport { ExportList } from './export-list';\nimport { typeNodeToSchema } from './transformers/utils/type-node-to-schema';\nimport { TransformerNotFound } from './exceptions';\nimport { parseTypeFromQuickInfo } from './transformers/utils/parse-type-from-quick-info';\n\nexport class SchemaExtractorContext {\n constructor(\n readonly tsserver: TsserverClient,\n readonly component: Component,\n readonly extractor: TypeScriptExtractor,\n readonly componentDeps: ComponentDependency[]\n ) {}\n\n computeSchema(node: Node) {\n return this.extractor.computeSchema(node, this);\n }\n\n /**\n * returns the location of a node in a source file.\n */\n getLocation(node: Node, targetSourceFile?: ts.SourceFile, absolutePath = false): Location {\n const sourceFile = targetSourceFile || node.getSourceFile();\n const position = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const line = position.line + 1;\n const character = position.character + 1;\n const filePath = absolutePath ? sourceFile.fileName : this.getPathRelativeToComponent(sourceFile.fileName);\n\n return {\n filePath: pathNormalizeToLinux(filePath),\n line,\n character,\n };\n }\n\n getLocationAsString(node: Node): string {\n const location = this.getLocation(node);\n return `${node.getSourceFile().fileName}, line: ${location.line}, character: ${location.character}`;\n }\n\n getPathRelativeToComponent(filePath: string): string {\n const basePath = this.component.filesystem.files[0].base;\n return relative(basePath, filePath);\n }\n\n /**\n * returns a signature for a node.\n */\n async getSignature(node: Node) {\n return this.tsserver.getSignatureHelp(this.getPath(node), this.getLocation(node));\n }\n\n /**\n * get the position for the tsserver.\n */\n getPosition(sourceFile: ts.SourceFile, line: number, offset: number): number {\n return sourceFile.getPositionOfLineAndCharacter(line - 1, offset - 1);\n }\n\n /**\n * get the path for a source file.\n */\n getPath(node: Node) {\n const sourceFile = node.getSourceFile();\n return sourceFile.fileName;\n }\n\n async getQuickInfo(node: Node) {\n const location = this.getLocation(node);\n try {\n return await this.tsserver.getQuickInfo(this.getPath(node), location);\n } catch (err: any) {\n if (err.message === 'No content available.') {\n throw new Error(\n `unable to get quickinfo data from tsserver at ${this.getPath(node)}, Ln ${location.line}, Col ${\n location.character\n }`\n );\n }\n throw err;\n }\n }\n\n async getQuickInfoDisplayString(node: Node): Promise<string> {\n const quickInfo = await this.getQuickInfo(node);\n return quickInfo?.body?.displayString || '';\n }\n\n /**\n * returns the type definition for a type.\n */\n typeDefinition(node: Node) {\n return this.tsserver.getTypeDefinition(this.getPath(node), this.getLocation(node));\n }\n\n visitTypeDefinition() {}\n\n private findFileInComponent(filePath: string) {\n return this.component.filesystem.files.find((file) => {\n // TODO: fix this line to support further extensions.\n if (file.path.includes(filePath)) {\n const strings = ['ts', 'tsx', 'js', 'jsx'].map((format) => {\n if (filePath.endsWith(format)) return filePath;\n return `${filePath}.${format}`;\n });\n\n return strings.find((string) => string === file.path);\n }\n\n return false;\n });\n }\n\n private parsePackageNameFromPath(path: string) {\n const parts = path.split('node_modules');\n if (parts.length === 1) return '';\n const lastPart = parts[parts.length - 1].replace(sep, '');\n const pkgParts = lastPart.split('/');\n if (lastPart.startsWith('@')) {\n // scoped package\n return `${pkgParts[0]}/${pkgParts[1]}`;\n }\n const pkgName = pkgParts[0];\n if (pkgName === 'typescript') {\n // it's a built-in type, such as \"string\".\n return '';\n }\n return pkgName;\n }\n\n /**\n * return the file if part of the component.\n * otherwise, a reference to the target package and the type name.\n */\n getSourceFileInsideComponent(filePath: string) {\n const file = this.findFileInComponent(filePath);\n if (!file) return undefined;\n return this.extractor.parseSourceFile(file);\n }\n\n async getSourceFileFromNode(node: Node) {\n const filePath = await this.getFilePathByNode(node);\n if (!filePath) {\n return undefined;\n }\n return this.getSourceFileInsideComponent(filePath);\n }\n\n async getFilePathByNode(node: Node) {\n const def = await this.tsserver.getDefinition(this.getPath(node), this.getLocation(node));\n\n const firstDef = head(def.body);\n return firstDef?.file;\n }\n\n async definitionInfo(node: Node): Promise<protocol.DefinitionInfo | undefined> {\n const location = this.getLocation(node);\n const filePath = this.getPath(node);\n\n const def = await this.tsserver.getDefinition(filePath, location);\n\n const firstDef = head(def.body);\n\n return firstDef;\n }\n\n /**\n * get a definition for a given node.\n */\n async definition(definitonInfo: protocol.DefinitionInfo): Promise<Node | undefined> {\n const startPosition = definitonInfo.start;\n const sourceFile = this.getSourceFileInsideComponent(definitonInfo.file);\n if (!sourceFile) {\n // it might be an external reference, cant get the node\n return undefined;\n }\n const pos = this.getPosition(sourceFile, startPosition.line, startPosition.offset);\n const nodeAtPos = getTokenAtPosition(sourceFile, pos);\n return nodeAtPos;\n }\n\n /**\n * visit a definition for node - e.g. return it's schema.\n */\n async visitDefinition(node: Node): Promise<SchemaNode | undefined> {\n const definitionInfo = await this.definitionInfo(node);\n if (!definitionInfo) {\n return undefined;\n }\n\n const definition = await this.definition(definitionInfo);\n if (!definition) {\n return this.getTypeRefForExternalNode(node);\n }\n\n return this.visit(definition.parent);\n }\n\n async visit(node: Node): Promise<SchemaNode> {\n return this.extractor.computeSchema(node, this);\n }\n\n references() {}\n\n isExported() {}\n\n isFromComponent() {}\n\n async getFileExports(exportDec: ExportDeclaration | ExportAssignment) {\n const file = exportDec.getSourceFile().fileName;\n const specifierPathStr =\n (exportDec.kind === SyntaxKind.ExportDeclaration && exportDec.moduleSpecifier?.getText()) || '';\n const specifierPath = specifierPathStr.substring(1, specifierPathStr.length - 1);\n const absPath = resolve(file, '..', specifierPath);\n const sourceFile = this.getSourceFileInsideComponent(absPath);\n if (!sourceFile) return [];\n return this.extractor.computeExportedIdentifiers(sourceFile, this);\n }\n\n _exports: ExportList | undefined = undefined;\n\n setExports(exports: ExportList) {\n this._exports = exports;\n return this;\n }\n\n getExportedIdentifiers(node: Node) {\n return this.extractor.computeExportedIdentifiers(node, this);\n }\n\n async jump(file: AbstractVinyl, start: any): Promise<SchemaNode | undefined> {\n const sourceFile = this.extractor.parseSourceFile(file);\n const pos = this.getPosition(sourceFile, start.line, start.offset);\n const nodeAtPos = getTokenAtPosition(sourceFile, pos);\n if (!nodeAtPos) return undefined;\n\n // this causes some infinite loops. it's helpful for getting more data from types that are not exported.\n // e.g.\n // ```ts\n // class Bar {}\n // export const getBar = () => new Bar();\n // ```\n // if (nodeAtPos.kind === ts.SyntaxKind.Identifier) {\n // // @todo: make sure with Ran that it's fine. Maybe it's better to do: `this.visit(nodeAtPos.parent);`\n // return this.visitDefinition(nodeAtPos);\n // }\n try {\n return await this.visit(nodeAtPos);\n } catch (err) {\n if (err instanceof TransformerNotFound) {\n return undefined;\n }\n throw err;\n }\n }\n\n /**\n * resolve a type by a node and its identifier.\n */\n async resolveType(\n node: Node & { type?: TypeNode },\n typeStr: string,\n isTypeStrFromQuickInfo = true\n ): Promise<SchemaNode> {\n const location = this.getLocation(node);\n if (this._exports?.includes(typeStr)) {\n return new TypeRefSchema(location, typeStr);\n }\n if (node.type && ts.isTypeNode(node.type)) {\n // if a node has \"type\" prop, it has the type data of the node. this normally happens when the code has the type\n // explicitly, e.g. `const str: string` vs implicitly `const str = 'some-string'`, which the node won't have \"type\"\n return typeNodeToSchema(node.type, this);\n }\n /**\n * tsserver has two different calls: \"definition\" and \"typeDefinition\".\n * normally, we need the \"typeDefinition\" to get the type data of a node.\n * sometimes, it has no data, for example when the node is of type TypeReference, and then using \"definition\" is\n * helpful. (couldn't find a rule when to use each one. e.g. \"VariableDeclaration\" sometimes has data only in\n * \"definition\" but it's not clear when/why).\n */\n const getDef = async () => {\n const typeDefinition = await this.typeDefinition(node);\n const headTypeDefinition = head(typeDefinition?.body);\n if (headTypeDefinition) {\n return headTypeDefinition;\n }\n const definition = await this.tsserver.getDefinition(node.getSourceFile().fileName, this.getLocation(node));\n return head(definition?.body);\n };\n const definition = await getDef();\n\n // when we can't figure out the component/package/type of this node, we'll use the typeStr as the type.\n const unknownExactType = async () => {\n if (isTypeStrFromQuickInfo) {\n return new InferenceTypeSchema(location, typeStr || 'any');\n }\n const info = await this.getQuickInfo(node);\n const type = parseTypeFromQuickInfo(info);\n return new InferenceTypeSchema(location, type, typeStr);\n };\n if (!definition) {\n return unknownExactType();\n }\n\n // the reason for this check is to avoid infinite loop when calling `this.jump` with the same file+location\n const isDefInSameLocation = () => {\n if (definition.file !== node.getSourceFile().fileName) {\n return false;\n }\n const loc = this.getLocation(node);\n return loc.line === definition.start.line && loc.character === definition.start.offset;\n };\n\n const file = this.findFileInComponent(definition.file);\n if (file) {\n if (isDefInSameLocation()) {\n return unknownExactType();\n }\n const schemaNode = await this.jump(file, definition.start);\n return schemaNode || unknownExactType();\n }\n return this.getTypeRefForExternalPath(typeStr, definition.file, location);\n }\n\n private getCompIdByPkgName(pkgName: string): ComponentID | undefined {\n return this.componentDeps.find((dep) => dep.packageName === pkgName)?.componentId;\n }\n\n async getTypeRefForExternalNode(node: Node): Promise<TypeRefSchema> {\n const info = await this.getQuickInfo(node);\n const typeStr = parseTypeFromQuickInfo(info);\n const location = this.getLocation(node);\n const filePath = this.getPath(node);\n return this.getTypeRefForExternalPath(typeStr, filePath, location);\n }\n\n async getTypeRefForExternalPath(typeStr: string, filePath: string, location: Location): Promise<TypeRefSchema> {\n const compIdByPath = await this.extractor.getComponentIDByPath(filePath);\n if (compIdByPath) {\n return new TypeRefSchema(location, typeStr, compIdByPath);\n }\n const pkgName = this.parsePackageNameFromPath(filePath);\n const compIdByPkg = this.getCompIdByPkgName(pkgName);\n if (compIdByPkg) {\n return new TypeRefSchema(location, typeStr, compIdByPkg);\n }\n return new TypeRefSchema(location, typeStr, undefined, pkgName);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EA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Ae,EAAE3F,QAAgB,EAAEK,QAAkB,EAA0B;IAC7G,MAAM2G,YAAY,GAAG,MAAM,IAAI,CAAC/H,SAAS,CAACgI,oBAAoB,CAACjH,QAAQ,CAAC;IACxE,IAAIgH,YAAY,EAAE;MAChB,OAAO,KAAInB,kCAAa,EAACxF,QAAQ,EAAEsF,OAAO,EAAEqB,YAAY,CAAC;IAC3D;IACA,MAAMjE,OAAO,GAAG,IAAI,CAACT,wBAAwB,CAACtC,QAAQ,CAAC;IACvD,MAAMkH,WAAW,GAAG,IAAI,CAACN,kBAAkB,CAAC7D,OAAO,CAAC;IACpD,IAAImE,WAAW,EAAE;MACf,OAAO,KAAIrB,kCAAa,EAACxF,QAAQ,EAAEsF,OAAO,EAAEuB,WAAW,CAAC;IAC1D;IACA,OAAO,KAAIrB,kCAAa,EAACxF,QAAQ,EAAEsF,OAAO,EAAExG,SAAS,EAAE4D,OAAO,CAAC;EACjE;AACF;AAAC"}
1
+ {"version":3,"names":["SchemaExtractorContext","constructor","tsserver","component","extractor","componentDeps","formatter","undefined","computeSchema","node","getLocation","targetSourceFile","absolutePath","sourceFile","getSourceFile","position","getLineAndCharacterOfPosition","getStart","line","character","filePath","fileName","getPathRelativeToComponent","pathNormalizeToLinux","getLocationAsString","location","basePath","filesystem","files","base","relative","getSignature","getSignatureHelp","getPath","getPosition","offset","getPositionOfLineAndCharacter","getQuickInfo","err","message","Error","getQuickInfoDisplayString","quickInfo","body","displayString","typeDefinition","getTypeDefinition","visitTypeDefinition","findFileInComponent","find","file","path","includes","strings","map","format","endsWith","string","parsePackageNameFromPath","parts","split","length","lastPart","replace","sep","pkgParts","startsWith","pkgName","getSourceFileInsideComponent","parseSourceFile","getSourceFileFromNode","getFilePathByNode","def","getDefinition","firstDef","head","definitionInfo","definition","startPosition","start","pos","nodeAtPos","getTokenAtPosition","visitDefinition","getTypeRefForExternalNode","visit","parent","references","isExported","isFromComponent","getFileExports","exportDec","specifierPathStr","kind","SyntaxKind","ExportDeclaration","moduleSpecifier","getText","specifierPath","substring","absPath","resolve","computeExportedIdentifiers","setExports","exports","_exports","getExportedIdentifiers","jump","TransformerNotFound","resolveType","typeStr","isTypeStrFromQuickInfo","TypeRefSchema","type","ts","isTypeNode","typeNodeToSchema","getDef","headTypeDefinition","unknownExactType","InferenceTypeSchema","info","parseTypeFromQuickInfo","isDefInSameLocation","loc","schemaNode","getTypeRefForExternalPath","getCompIdByPkgName","dep","packageName","componentId","compIdByPath","getComponentIDByPath","compIdByPkg","jsDocToDocSchema","canHaveJsDoc","jsDocs","getJsDoc","jsDoc","comment","getTextOfJSDocComment","tags","pMapSeries","tag","tagParser","DocSchema"],"sources":["schema-extractor-context.ts"],"sourcesContent":["import { TsserverClient } from '@teambit/ts-server';\nimport { getTokenAtPosition, canHaveJsDoc, getJsDoc } from 'tsutils';\nimport ts, { ExportAssignment, getTextOfJSDocComment, ExportDeclaration, Node, SyntaxKind, TypeNode } from 'typescript';\nimport { head } from 'lodash';\n// eslint-disable-next-line import/no-unresolved\nimport protocol from 'typescript/lib/protocol';\n// @ts-ignore david we should figure fix this.\nimport type { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport { resolve, sep, relative } from 'path';\nimport { Component, ComponentID } from '@teambit/component';\nimport {\n TypeRefSchema,\n SchemaNode,\n InferenceTypeSchema,\n Location,\n DocSchema,\n} from '@teambit/semantics.entities.semantic-schema';\nimport { ComponentDependency } from '@teambit/dependency-resolver';\nimport { Formatter } from '@teambit/formatter';\nimport pMapSeries from 'p-map-series';\nimport { TypeScriptExtractor } from './typescript.extractor';\nimport { ExportList } from './export-list';\nimport { typeNodeToSchema } from './transformers/utils/type-node-to-schema';\nimport { TransformerNotFound } from './exceptions';\nimport { parseTypeFromQuickInfo } from './transformers/utils/parse-type-from-quick-info';\nimport { tagParser } from './transformers/utils/jsdoc-to-doc-schema';\n\nexport class SchemaExtractorContext {\n constructor(\n readonly tsserver: TsserverClient,\n readonly component: Component,\n readonly extractor: TypeScriptExtractor,\n readonly componentDeps: ComponentDependency[],\n readonly formatter: Formatter\n ) {}\n\n computeSchema(node: Node) {\n return this.extractor.computeSchema(node, this);\n }\n\n /**\n * returns the location of a node in a source file.\n */\n getLocation(node: Node, targetSourceFile?: ts.SourceFile, absolutePath = false): Location {\n const sourceFile = targetSourceFile || node.getSourceFile();\n const position = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const line = position.line + 1;\n const character = position.character + 1;\n const filePath = absolutePath ? sourceFile.fileName : this.getPathRelativeToComponent(sourceFile.fileName);\n\n return {\n filePath: pathNormalizeToLinux(filePath),\n line,\n character,\n };\n }\n\n getLocationAsString(node: Node): string {\n const location = this.getLocation(node);\n return `${node.getSourceFile().fileName}, line: ${location.line}, character: ${location.character}`;\n }\n\n getPathRelativeToComponent(filePath: string): string {\n const basePath = this.component.filesystem.files[0].base;\n return relative(basePath, filePath);\n }\n\n /**\n * returns a signature for a node.\n */\n async getSignature(node: Node) {\n return this.tsserver.getSignatureHelp(this.getPath(node), this.getLocation(node));\n }\n\n /**\n * get the position for the tsserver.\n */\n getPosition(sourceFile: ts.SourceFile, line: number, offset: number): number {\n return sourceFile.getPositionOfLineAndCharacter(line - 1, offset - 1);\n }\n\n /**\n * get the path for a source file.\n */\n getPath(node: Node) {\n const sourceFile = node.getSourceFile();\n return sourceFile.fileName;\n }\n\n async getQuickInfo(node: Node) {\n const location = this.getLocation(node);\n try {\n return await this.tsserver.getQuickInfo(this.getPath(node), location);\n } catch (err: any) {\n if (err.message === 'No content available.') {\n throw new Error(\n `unable to get quickinfo data from tsserver at ${this.getPath(node)}, Ln ${location.line}, Col ${\n location.character\n }`\n );\n }\n throw err;\n }\n }\n\n async getQuickInfoDisplayString(node: Node): Promise<string> {\n const quickInfo = await this.getQuickInfo(node);\n return quickInfo?.body?.displayString || '';\n }\n\n /**\n * returns the type definition for a type.\n */\n typeDefinition(node: Node) {\n return this.tsserver.getTypeDefinition(this.getPath(node), this.getLocation(node));\n }\n\n visitTypeDefinition() {}\n\n private findFileInComponent(filePath: string) {\n return this.component.filesystem.files.find((file) => {\n // TODO: fix this line to support further extensions.\n if (file.path.includes(filePath)) {\n const strings = ['ts', 'tsx', 'js', 'jsx'].map((format) => {\n if (filePath.endsWith(format)) return filePath;\n return `${filePath}.${format}`;\n });\n\n return strings.find((string) => string === file.path);\n }\n\n return false;\n });\n }\n\n private parsePackageNameFromPath(path: string) {\n const parts = path.split('node_modules');\n if (parts.length === 1) return '';\n const lastPart = parts[parts.length - 1].replace(sep, '');\n const pkgParts = lastPart.split('/');\n if (lastPart.startsWith('@')) {\n // scoped package\n return `${pkgParts[0]}/${pkgParts[1]}`;\n }\n const pkgName = pkgParts[0];\n if (pkgName === 'typescript') {\n // it's a built-in type, such as \"string\".\n return '';\n }\n return pkgName;\n }\n\n /**\n * return the file if part of the component.\n * otherwise, a reference to the target package and the type name.\n */\n getSourceFileInsideComponent(filePath: string) {\n const file = this.findFileInComponent(filePath);\n if (!file) return undefined;\n return this.extractor.parseSourceFile(file);\n }\n\n async getSourceFileFromNode(node: Node) {\n const filePath = await this.getFilePathByNode(node);\n if (!filePath) {\n return undefined;\n }\n return this.getSourceFileInsideComponent(filePath);\n }\n\n async getFilePathByNode(node: Node) {\n const def = await this.tsserver.getDefinition(this.getPath(node), this.getLocation(node));\n\n const firstDef = head(def.body);\n return firstDef?.file;\n }\n\n async definitionInfo(node: Node): Promise<protocol.DefinitionInfo | undefined> {\n const location = this.getLocation(node);\n const filePath = this.getPath(node);\n\n const def = await this.tsserver.getDefinition(filePath, location);\n\n const firstDef = head(def.body);\n\n return firstDef;\n }\n\n /**\n * get a definition for a given node.\n */\n async definition(definition: protocol.DefinitionInfo): Promise<Node | undefined> {\n const startPosition = definition.start;\n const sourceFile = this.getSourceFileInsideComponent(definition.file);\n if (!sourceFile) {\n // it might be an external reference, cant get the node\n return undefined;\n }\n const pos = this.getPosition(sourceFile, startPosition.line, startPosition.offset);\n const nodeAtPos = getTokenAtPosition(sourceFile, pos);\n return nodeAtPos;\n }\n\n /**\n * visit a definition for node - e.g. return it's schema.\n */\n async visitDefinition(node: Node): Promise<SchemaNode | undefined> {\n const definitionInfo = await this.definitionInfo(node);\n if (!definitionInfo) {\n return undefined;\n }\n\n const definition = await this.definition(definitionInfo);\n if (!definition) {\n return this.getTypeRefForExternalNode(node);\n }\n\n return this.visit(definition.parent);\n }\n\n async visit(node: Node): Promise<SchemaNode> {\n return this.extractor.computeSchema(node, this);\n }\n\n references() {}\n\n isExported() {}\n\n isFromComponent() {}\n\n async getFileExports(exportDec: ExportDeclaration | ExportAssignment) {\n const file = exportDec.getSourceFile().fileName;\n const specifierPathStr =\n (exportDec.kind === SyntaxKind.ExportDeclaration && exportDec.moduleSpecifier?.getText()) || '';\n const specifierPath = specifierPathStr.substring(1, specifierPathStr.length - 1);\n const absPath = resolve(file, '..', specifierPath);\n const sourceFile = this.getSourceFileInsideComponent(absPath);\n if (!sourceFile) return [];\n return this.extractor.computeExportedIdentifiers(sourceFile, this);\n }\n\n _exports: ExportList | undefined = undefined;\n\n setExports(exports: ExportList) {\n this._exports = exports;\n return this;\n }\n\n getExportedIdentifiers(node: Node) {\n return this.extractor.computeExportedIdentifiers(node, this);\n }\n\n async jump(file: AbstractVinyl, start: any): Promise<SchemaNode | undefined> {\n const sourceFile = this.extractor.parseSourceFile(file);\n const pos = this.getPosition(sourceFile, start.line, start.offset);\n const nodeAtPos = getTokenAtPosition(sourceFile, pos);\n if (!nodeAtPos) return undefined;\n\n // this causes some infinite loops. it's helpful for getting more data from types that are not exported.\n // e.g.\n // ```ts\n // class Bar {}\n // export const getBar = () => new Bar();\n // ```\n // if (nodeAtPos.kind === ts.SyntaxKind.Identifier) {\n // // @todo: make sure with Ran that it's fine. Maybe it's better to do: `this.visit(nodeAtPos.parent);`\n // return this.visitDefinition(nodeAtPos);\n // }\n try {\n return await this.visit(nodeAtPos);\n } catch (err) {\n if (err instanceof TransformerNotFound) {\n return undefined;\n }\n throw err;\n }\n }\n\n /**\n * resolve a type by a node and its identifier.\n */\n async resolveType(\n node: Node & { type?: TypeNode },\n typeStr: string,\n isTypeStrFromQuickInfo = true\n ): Promise<SchemaNode> {\n const location = this.getLocation(node);\n if (this._exports?.includes(typeStr)) {\n return new TypeRefSchema(location, typeStr);\n }\n if (node.type && ts.isTypeNode(node.type)) {\n // if a node has \"type\" prop, it has the type data of the node. this normally happens when the code has the type\n // explicitly, e.g. `const str: string` vs implicitly `const str = 'some-string'`, which the node won't have \"type\"\n return typeNodeToSchema(node.type, this);\n }\n /**\n * tsserver has two different calls: \"definition\" and \"typeDefinition\".\n * normally, we need the \"typeDefinition\" to get the type data of a node.\n * sometimes, it has no data, for example when the node is of type TypeReference, and then using \"definition\" is\n * helpful. (couldn't find a rule when to use each one. e.g. \"VariableDeclaration\" sometimes has data only in\n * \"definition\" but it's not clear when/why).\n */\n const getDef = async () => {\n const typeDefinition = await this.typeDefinition(node);\n const headTypeDefinition = head(typeDefinition?.body);\n if (headTypeDefinition) {\n return headTypeDefinition;\n }\n const definition = await this.tsserver.getDefinition(node.getSourceFile().fileName, this.getLocation(node));\n return head(definition?.body);\n };\n const definition = await getDef();\n\n // when we can't figure out the component/package/type of this node, we'll use the typeStr as the type.\n const unknownExactType = async () => {\n if (isTypeStrFromQuickInfo) {\n return new InferenceTypeSchema(location, typeStr || 'any');\n }\n const info = await this.getQuickInfo(node);\n const type = parseTypeFromQuickInfo(info);\n return new InferenceTypeSchema(location, type, typeStr);\n };\n if (!definition) {\n return unknownExactType();\n }\n\n // the reason for this check is to avoid infinite loop when calling `this.jump` with the same file+location\n const isDefInSameLocation = () => {\n if (definition.file !== node.getSourceFile().fileName) {\n return false;\n }\n const loc = this.getLocation(node);\n return loc.line === definition.start.line && loc.character === definition.start.offset;\n };\n\n const file = this.findFileInComponent(definition.file);\n if (file) {\n if (isDefInSameLocation()) {\n return unknownExactType();\n }\n const schemaNode = await this.jump(file, definition.start);\n return schemaNode || unknownExactType();\n }\n return this.getTypeRefForExternalPath(typeStr, definition.file, location);\n }\n\n private getCompIdByPkgName(pkgName: string): ComponentID | undefined {\n return this.componentDeps.find((dep) => dep.packageName === pkgName)?.componentId;\n }\n\n async getTypeRefForExternalNode(node: Node): Promise<TypeRefSchema> {\n const info = await this.getQuickInfo(node);\n const typeStr = parseTypeFromQuickInfo(info);\n const location = this.getLocation(node);\n const filePath = this.getPath(node);\n return this.getTypeRefForExternalPath(typeStr, filePath, location);\n }\n\n async getTypeRefForExternalPath(typeStr: string, filePath: string, location: Location): Promise<TypeRefSchema> {\n const compIdByPath = await this.extractor.getComponentIDByPath(filePath);\n if (compIdByPath) {\n return new TypeRefSchema(location, typeStr, compIdByPath);\n }\n const pkgName = this.parsePackageNameFromPath(filePath);\n const compIdByPkg = this.getCompIdByPkgName(pkgName);\n if (compIdByPkg) {\n return new TypeRefSchema(location, typeStr, compIdByPkg);\n }\n return new TypeRefSchema(location, typeStr, undefined, pkgName);\n }\n\n async jsDocToDocSchema(node: Node): Promise<DocSchema | undefined> {\n if (!canHaveJsDoc(node)) {\n return undefined;\n }\n const jsDocs = getJsDoc(node);\n if (!jsDocs.length) {\n return undefined;\n }\n // not sure how common it is to have multiple JSDocs. never seen it before.\n // regardless, in typescript implementation of methods like `getJSDocDeprecatedTag()`, they use the first one. (`getFirstJSDocTag()`)\n const jsDoc = jsDocs[0];\n const location = this.getLocation(jsDoc);\n const comment = getTextOfJSDocComment(jsDoc.comment);\n const tags = jsDoc.tags ? await pMapSeries(jsDoc.tags, (tag) => tagParser(tag, this, this.formatter)) : undefined;\n return new DocSchema(location, jsDoc.getText(), comment, tags);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAA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6BAAS,EAACD,GAAG,EAAE,IAAI,EAAE,IAAI,CAACzI,SAAS,CAAC,CAAC,GAAGC,SAAS;IACjH,OAAO,KAAI0I,8BAAS,EAACxH,QAAQ,EAAEiH,KAAK,CAACzC,OAAO,EAAE,EAAE0C,OAAO,EAAEE,IAAI,CAAC;EAChE;AACF;AAAC"}
@@ -34,13 +34,6 @@ function _parseTypeFromQuickInfo() {
34
34
  };
35
35
  return data;
36
36
  }
37
- function _jsdocToDocSchema() {
38
- const data = require("./utils/jsdoc-to-doc-schema");
39
- _jsdocToDocSchema = function () {
40
- return data;
41
- };
42
- return data;
43
- }
44
37
  /**
45
38
  * for example:
46
39
  *
@@ -62,7 +55,7 @@ class BindingElementTransformer {
62
55
  const displaySig = (info === null || info === void 0 ? void 0 : (_info$body = info.body) === null || _info$body === void 0 ? void 0 : _info$body.displayString) || '';
63
56
  const typeStr = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
64
57
  const type = await context.resolveType(node, typeStr);
65
- const doc = await (0, _jsdocToDocSchema().jsDocToDocSchema)(node, context);
58
+ const doc = await context.jsDocToDocSchema(node);
66
59
  return new (_semanticsEntities().VariableLikeSchema)(context.getLocation(node), name, displaySig, type, false, doc);
67
60
  }
68
61
  }
@@ -1 +1 @@
1
- {"version":3,"names":["BindingElementTransformer","predicate","node","kind","ts","SyntaxKind","BindingElement","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","transform","context","info","getQuickInfo","displaySig","body","displayString","typeStr","parseTypeFromQuickInfo","type","resolveType","doc","jsDocToDocSchema","VariableLikeSchema","getLocation"],"sources":["binding-element.ts"],"sourcesContent":["import ts, { BindingElement, Node } from 'typescript';\nimport { VariableLikeSchema } from '@teambit/semantics.entities.semantic-schema';\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 { jsDocToDocSchema } from './utils/jsdoc-to-doc-schema';\n\n/**\n * for example:\n *\n * const objBindingElem = { elem1: 1, elem2: 2 };\n * const { elem1 } = objBindingElem;\n * export { elem1 };\n */\nexport class BindingElementTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.BindingElement;\n }\n\n async getIdentifiers(node: BindingElement) {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(node: BindingElement, 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 const doc = await jsDocToDocSchema(node, context);\n return new VariableLikeSchema(context.getLocation(node), name, displaySig, type, false, doc);\n }\n}\n"],"mappings":";;;;;;;;AAAA;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;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,yBAAyB,CAA8B;EAClEC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACC,cAAc;EACnD;EAEA,MAAMC,cAAc,CAACL,IAAoB,EAAE;IACzC,OAAO,CAAC,KAAIM,oCAAgB,EAACN,IAAI,CAACO,IAAI,CAACC,OAAO,EAAE,EAAER,IAAI,CAACS,aAAa,EAAE,CAACC,QAAQ,CAAC,CAAC;EACnF;EAEA,MAAMC,SAAS,CAACX,IAAoB,EAAEY,OAA+B,EAAE;IAAA;IACrE,MAAML,IAAI,GAAGP,IAAI,CAACO,IAAI,CAACC,OAAO,EAAE;IAChC,MAAMK,IAAI,GAAG,MAAMD,OAAO,CAACE,YAAY,CAACd,IAAI,CAACO,IAAI,CAAC;IAClD,MAAMQ,UAAU,GAAG,CAAAF,IAAI,aAAJA,IAAI,qCAAJA,IAAI,CAAEG,IAAI,+CAAV,WAAYC,aAAa,KAAI,EAAE;IAClD,MAAMC,OAAO,GAAG,IAAAC,gDAAsB,EAACN,IAAI,CAAC;IAC5C,MAAMO,IAAI,GAAG,MAAMR,OAAO,CAACS,WAAW,CAACrB,IAAI,EAAEkB,OAAO,CAAC;IACrD,MAAMI,GAAG,GAAG,MAAM,IAAAC,oCAAgB,EAACvB,IAAI,EAAEY,OAAO,CAAC;IACjD,OAAO,KAAIY,uCAAkB,EAACZ,OAAO,CAACa,WAAW,CAACzB,IAAI,CAAC,EAAEO,IAAI,EAAEQ,UAAU,EAAEK,IAAI,EAAE,KAAK,EAAEE,GAAG,CAAC;EAC9F;AACF;AAAC"}
1
+ {"version":3,"names":["BindingElementTransformer","predicate","node","kind","ts","SyntaxKind","BindingElement","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","transform","context","info","getQuickInfo","displaySig","body","displayString","typeStr","parseTypeFromQuickInfo","type","resolveType","doc","jsDocToDocSchema","VariableLikeSchema","getLocation"],"sources":["binding-element.ts"],"sourcesContent":["import ts, { BindingElement, Node } from 'typescript';\nimport { VariableLikeSchema } from '@teambit/semantics.entities.semantic-schema';\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';\n\n/**\n * for example:\n *\n * const objBindingElem = { elem1: 1, elem2: 2 };\n * const { elem1 } = objBindingElem;\n * export { elem1 };\n */\nexport class BindingElementTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.BindingElement;\n }\n\n async getIdentifiers(node: BindingElement) {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(node: BindingElement, 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 const doc = await context.jsDocToDocSchema(node);\n return new VariableLikeSchema(context.getLocation(node), name, displaySig, type, false, doc);\n }\n}\n"],"mappings":";;;;;;;;AAAA;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;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,yBAAyB,CAA8B;EAClEC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACC,cAAc;EACnD;EAEA,MAAMC,cAAc,CAACL,IAAoB,EAAE;IACzC,OAAO,CAAC,KAAIM,oCAAgB,EAACN,IAAI,CAACO,IAAI,CAACC,OAAO,EAAE,EAAER,IAAI,CAACS,aAAa,EAAE,CAACC,QAAQ,CAAC,CAAC;EACnF;EAEA,MAAMC,SAAS,CAACX,IAAoB,EAAEY,OAA+B,EAAE;IAAA;IACrE,MAAML,IAAI,GAAGP,IAAI,CAACO,IAAI,CAACC,OAAO,EAAE;IAChC,MAAMK,IAAI,GAAG,MAAMD,OAAO,CAACE,YAAY,CAACd,IAAI,CAACO,IAAI,CAAC;IAClD,MAAMQ,UAAU,GAAG,CAAAF,IAAI,aAAJA,IAAI,qCAAJA,IAAI,CAAEG,IAAI,+CAAV,WAAYC,aAAa,KAAI,EAAE;IAClD,MAAMC,OAAO,GAAG,IAAAC,gDAAsB,EAACN,IAAI,CAAC;IAC5C,MAAMO,IAAI,GAAG,MAAMR,OAAO,CAACS,WAAW,CAACrB,IAAI,EAAEkB,OAAO,CAAC;IACrD,MAAMI,GAAG,GAAG,MAAMV,OAAO,CAACW,gBAAgB,CAACvB,IAAI,CAAC;IAChD,OAAO,KAAIwB,uCAAkB,EAACZ,OAAO,CAACa,WAAW,CAACzB,IAAI,CAAC,EAAEO,IAAI,EAAEQ,UAAU,EAAEK,IAAI,EAAE,KAAK,EAAEE,GAAG,CAAC;EAC9F;AACF;AAAC"}
@@ -3,9 +3,10 @@ import { Node, ClassDeclaration } from 'typescript';
3
3
  import { SchemaTransformer } from '../schema-transformer';
4
4
  import { SchemaExtractorContext } from '../schema-extractor-context';
5
5
  import { ExportIdentifier } from '../export-identifier';
6
- export declare class ClassDecelerationTransformer implements SchemaTransformer {
6
+ export declare class ClassDeclarationTransformer implements SchemaTransformer {
7
7
  predicate(node: Node): boolean;
8
8
  private getName;
9
9
  getIdentifiers(node: ClassDeclaration): Promise<ExportIdentifier[]>;
10
+ private getExpressionWithTypeArgs;
10
11
  transform(node: ClassDeclaration, context: SchemaExtractorContext): Promise<ClassSchema>;
11
12
  }
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ require("core-js/modules/es.array.flat-map.js");
5
+ require("core-js/modules/es.array.unscopables.flat-map.js");
6
+ require("core-js/modules/es.promise.js");
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.ClassDeclarationTransformer = void 0;
11
+ function _defineProperty2() {
12
+ const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+ _defineProperty2 = function () {
14
+ return data;
15
+ };
16
+ return data;
17
+ }
18
+ function _pMapSeries() {
19
+ const data = _interopRequireDefault(require("p-map-series"));
20
+ _pMapSeries = function () {
21
+ return data;
22
+ };
23
+ return data;
24
+ }
25
+ function _lodash() {
26
+ const data = require("lodash");
27
+ _lodash = function () {
28
+ return data;
29
+ };
30
+ return data;
31
+ }
32
+ function _semanticsEntities() {
33
+ const data = require("@teambit/semantics.entities.semantic-schema");
34
+ _semanticsEntities = function () {
35
+ return data;
36
+ };
37
+ return data;
38
+ }
39
+ function _typescript() {
40
+ const data = _interopRequireDefault(require("typescript"));
41
+ _typescript = function () {
42
+ return data;
43
+ };
44
+ return data;
45
+ }
46
+ function _exportIdentifier() {
47
+ const data = require("../export-identifier");
48
+ _exportIdentifier = function () {
49
+ return data;
50
+ };
51
+ return data;
52
+ }
53
+ function _classElementToSchema() {
54
+ const data = require("./utils/class-element-to-schema");
55
+ _classElementToSchema = function () {
56
+ return data;
57
+ };
58
+ return data;
59
+ }
60
+ function _typeNodeToSchema() {
61
+ const data = require("./utils/type-node-to-schema");
62
+ _typeNodeToSchema = function () {
63
+ return data;
64
+ };
65
+ return data;
66
+ }
67
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
68
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
69
+ class ClassDeclarationTransformer {
70
+ predicate(node) {
71
+ return node.kind === _typescript().default.SyntaxKind.ClassDeclaration;
72
+ }
73
+
74
+ // @todo: in case of `export default class` the class has no name.
75
+ getName(node) {
76
+ var _node$name;
77
+ return ((_node$name = node.name) === null || _node$name === void 0 ? void 0 : _node$name.getText()) || 'default';
78
+ }
79
+ async getIdentifiers(node) {
80
+ return [new (_exportIdentifier().ExportIdentifier)(this.getName(node), node.getSourceFile().fileName)];
81
+ }
82
+ async getExpressionWithTypeArgs(node, context, token) {
83
+ if (!node.heritageClauses) return [];
84
+ return (0, _pMapSeries().default)(node.heritageClauses.filter(heritageClause => heritageClause.token === token).flatMap(h => {
85
+ const {
86
+ types
87
+ } = h;
88
+ const name = h.getText();
89
+ return types.map(type => _objectSpread(_objectSpread({}, type), {}, {
90
+ name
91
+ }));
92
+ }), async expressionWithTypeArgs => {
93
+ const {
94
+ typeArguments,
95
+ expression,
96
+ name
97
+ } = expressionWithTypeArgs;
98
+ const typeArgsNodes = typeArguments ? await (0, _pMapSeries().default)(typeArguments, t => (0, _typeNodeToSchema().typeNodeToSchema)(t, context)) : [];
99
+ const location = context.getLocation(expression);
100
+ const expressionNode = (await context.visitDefinition(expression)) || new (_semanticsEntities().UnresolvedSchema)(location, expression.getText());
101
+ return new (_semanticsEntities().ExpressionWithTypeArgumentsSchema)(typeArgsNodes, expressionNode, name, location);
102
+ });
103
+ }
104
+ async transform(node, context) {
105
+ var _node$typeParameters;
106
+ const className = this.getName(node);
107
+ const extendsExpressionsWithTypeArgs = await this.getExpressionWithTypeArgs(node, context, _typescript().default.SyntaxKind.ExtendsKeyword);
108
+ const implementsExpressionsWithTypeArgs = await this.getExpressionWithTypeArgs(node, context, _typescript().default.SyntaxKind.ImplementsKeyword);
109
+ const typeParameters = (_node$typeParameters = node.typeParameters) === null || _node$typeParameters === void 0 ? void 0 : _node$typeParameters.map(typeParam => {
110
+ return typeParam.name.getText();
111
+ });
112
+ const signature = node.name ? await context.getQuickInfoDisplayString(node.name) : undefined;
113
+ const members = await (0, _pMapSeries().default)(node.members, async member => {
114
+ var _member$modifiers;
115
+ const isPrivate = (_member$modifiers = member.modifiers) === null || _member$modifiers === void 0 ? void 0 : _member$modifiers.some(modifier => modifier.kind === _typescript().default.SyntaxKind.PrivateKeyword);
116
+ if (isPrivate) {
117
+ return null;
118
+ }
119
+ return (0, _classElementToSchema().classElementToSchema)(member, context);
120
+ });
121
+ const doc = await context.jsDocToDocSchema(node);
122
+ if (!signature) {
123
+ throw Error(`Missing signature for class ${className} declaration`);
124
+ }
125
+ return new (_semanticsEntities().ClassSchema)(className, (0, _lodash().compact)(members), context.getLocation(node), signature, doc, typeParameters, extendsExpressionsWithTypeArgs, implementsExpressionsWithTypeArgs);
126
+ }
127
+ }
128
+ exports.ClassDeclarationTransformer = ClassDeclarationTransformer;
129
+
130
+ //# sourceMappingURL=class-declaration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ClassDeclarationTransformer","predicate","node","kind","ts","SyntaxKind","ClassDeclaration","getName","name","getText","getIdentifiers","ExportIdentifier","getSourceFile","fileName","getExpressionWithTypeArgs","context","token","heritageClauses","pMapSeries","filter","heritageClause","flatMap","h","types","map","type","expressionWithTypeArgs","typeArguments","expression","typeArgsNodes","t","typeNodeToSchema","location","getLocation","expressionNode","visitDefinition","UnresolvedSchema","ExpressionWithTypeArgumentsSchema","transform","className","extendsExpressionsWithTypeArgs","ExtendsKeyword","implementsExpressionsWithTypeArgs","ImplementsKeyword","typeParameters","typeParam","signature","getQuickInfoDisplayString","undefined","members","member","isPrivate","modifiers","some","modifier","PrivateKeyword","classElementToSchema","doc","jsDocToDocSchema","Error","ClassSchema","compact"],"sources":["class-declaration.ts"],"sourcesContent":["import pMapSeries from 'p-map-series';\nimport { compact } from 'lodash';\nimport {\n ClassSchema,\n UnresolvedSchema,\n ExpressionWithTypeArgumentsSchema,\n} 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 { classElementToSchema } from './utils/class-element-to-schema';\nimport { typeNodeToSchema } from './utils/type-node-to-schema';\n\nexport class ClassDeclarationTransformer 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 private async getExpressionWithTypeArgs(\n node: ClassDeclaration,\n context: SchemaExtractorContext,\n token: ts.SyntaxKind.ExtendsKeyword | ts.SyntaxKind.ImplementsKeyword\n ) {\n if (!node.heritageClauses) return [];\n\n return pMapSeries(\n node.heritageClauses\n .filter((heritageClause: ts.HeritageClause) => heritageClause.token === token)\n .flatMap((h: ts.HeritageClause) => {\n const { types } = h;\n const name = h.getText();\n return types.map((type) => ({ ...type, name }));\n }),\n async (expressionWithTypeArgs: ts.ExpressionWithTypeArguments & { name: string }) => {\n const { typeArguments, expression, name } = expressionWithTypeArgs;\n const typeArgsNodes = typeArguments ? await pMapSeries(typeArguments, (t) => typeNodeToSchema(t, context)) : [];\n const location = context.getLocation(expression);\n const expressionNode =\n (await context.visitDefinition(expression)) || new UnresolvedSchema(location, expression.getText());\n return new ExpressionWithTypeArgumentsSchema(typeArgsNodes, expressionNode, name, location);\n }\n );\n }\n\n async transform(node: ClassDeclaration, context: SchemaExtractorContext) {\n const className = this.getName(node);\n const extendsExpressionsWithTypeArgs = await this.getExpressionWithTypeArgs(\n node,\n context,\n ts.SyntaxKind.ExtendsKeyword\n );\n\n const implementsExpressionsWithTypeArgs = await this.getExpressionWithTypeArgs(\n node,\n context,\n ts.SyntaxKind.ImplementsKeyword\n );\n\n const typeParameters = node.typeParameters?.map((typeParam) => {\n return typeParam.name.getText();\n });\n const signature = node.name ? await context.getQuickInfoDisplayString(node.name) : undefined;\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 context.jsDocToDocSchema(node);\n\n if (!signature) {\n throw Error(`Missing signature for class ${className} declaration`);\n }\n\n return new ClassSchema(\n className,\n compact(members),\n context.getLocation(node),\n signature,\n doc,\n typeParameters,\n extendsExpressionsWithTypeArgs,\n implementsExpression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CAACM,IAAI,GAAG,MAAMO,OAAO,CAACgC,yBAAyB,CAAC7C,IAAI,CAACM,IAAI,CAAC,GAAGwC,SAAS;IAC5F,MAAMC,OAAO,GAAG,MAAM,IAAA/B,qBAAU,EAAChB,IAAI,CAAC+C,OAAO,EAAE,MAAOC,MAAM,IAAK;MAAA;MAC/D,MAAMC,SAAS,wBAAGD,MAAM,CAACE,SAAS,sDAAhB,kBAAkBC,IAAI,CAAEC,QAAQ,IAAKA,QAAQ,CAACnD,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACkD,cAAc,CAAC;MACtG,IAAIJ,SAAS,EAAE;QACb,OAAO,IAAI;MACb;MACA,OAAO,IAAAK,4CAAoB,EAACN,MAAM,EAAEnC,OAAO,CAAC;IAC9C,CAAC,CAAC;IACF,MAAM0C,GAAG,GAAG,MAAM1C,OAAO,CAAC2C,gBAAgB,CAACxD,IAAI,CAAC;IAEhD,IAAI,CAAC4C,SAAS,EAAE;MACd,MAAMa,KAAK,CAAE,+BAA8BpB,SAAU,cAAa,CAAC;IACrE;IAEA,OAAO,KAAIqB,gCAAW,EACpBrB,SAAS,EACT,IAAAsB,iBAAO,EAACZ,OAAO,CAAC,EAChBlC,OAAO,CAACkB,WAAW,CAAC/B,IAAI,CAAC,EACzB4C,SAAS,EACTW,GAAG,EACHb,cAAc,EACdJ,8BAA8B,EAC9BE,iCAAiC,CAClC;EACH;AACF;AAAC"}
@@ -20,6 +20,13 @@ function _semanticsEntities() {
20
20
  };
21
21
  return data;
22
22
  }
23
+ function _pMapSeries() {
24
+ const data = _interopRequireDefault(require("p-map-series"));
25
+ _pMapSeries = function () {
26
+ return data;
27
+ };
28
+ return data;
29
+ }
23
30
  function _exportIdentifier() {
24
31
  const data = require("../export-identifier");
25
32
  _exportIdentifier = function () {
@@ -35,8 +42,19 @@ class EnumDeclarationTransformer {
35
42
  return [new (_exportIdentifier().ExportIdentifier)(node.name.getText(), node.getSourceFile().fileName)];
36
43
  }
37
44
  async transform(enumDec, context) {
38
- const members = enumDec.members.map(member => member.name.getText());
39
- return new (_semanticsEntities().EnumSchema)(context.getLocation(enumDec), enumDec.name.getText(), members);
45
+ const name = enumDec.name.getText();
46
+ const members = await (0, _pMapSeries().default)(enumDec.members, async member => {
47
+ var _member$initializer;
48
+ const memberName = member.name.getText();
49
+ const memberSignature = await context.getQuickInfoDisplayString(member);
50
+ const memberDoc = await context.jsDocToDocSchema(member);
51
+ const memberLocation = await context.getLocation(member);
52
+ const memberValue = (_member$initializer = member.initializer) === null || _member$initializer === void 0 ? void 0 : _member$initializer.getText();
53
+ return new (_semanticsEntities().EnumMemberSchema)(memberLocation, memberName, memberSignature, memberValue, memberDoc);
54
+ });
55
+ const signature = await context.getQuickInfoDisplayString(enumDec.name);
56
+ const doc = await context.jsDocToDocSchema(enumDec);
57
+ return new (_semanticsEntities().EnumSchema)(context.getLocation(enumDec), name, members, signature, doc);
40
58
  }
41
59
  }
42
60
  exports.EnumDeclarationTransformer = EnumDeclarationTransformer;
@@ -1 +1 @@
1
- {"version":3,"names":["EnumDeclarationTransformer","predicate","node","kind","ts","SyntaxKind","EnumDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","transform","enumDec","context","members","map","member","EnumSchema","getLocation"],"sources":["enum-declaration.ts"],"sourcesContent":["import ts, { Node, EnumDeclaration } from 'typescript';\nimport { EnumSchema } 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 EnumDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.EnumDeclaration;\n }\n\n async getIdentifiers(node: EnumDeclaration): Promise<ExportIdentifier[]> {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(enumDec: EnumDeclaration, context: SchemaExtractorContext) {\n const members = enumDec.members.map((member) => member.name.getText());\n return new EnumSchema(context.getLocation(enumDec), enumDec.name.getText(), members);\n }\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,0BAA0B,CAA8B;EACnEC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACC,eAAe;EACpD;EAEA,MAAMC,cAAc,CAACL,IAAqB,EAA+B;IACvE,OAAO,CAAC,KAAIM,oCAAgB,EAACN,IAAI,CAACO,IAAI,CAACC,OAAO,EAAE,EAAER,IAAI,CAACS,aAAa,EAAE,CAACC,QAAQ,CAAC,CAAC;EACnF;EAEA,MAAMC,SAAS,CAACC,OAAwB,EAAEC,OAA+B,EAAE;IACzE,MAAMC,OAAO,GAAGF,OAAO,CAACE,OAAO,CAACC,GAAG,CAAEC,MAAM,IAAKA,MAAM,CAACT,IAAI,CAACC,OAAO,EAAE,CAAC;IACtE,OAAO,KAAIS,+BAAU,EAACJ,OAAO,CAACK,WAAW,CAACN,OAAO,CAAC,EAAEA,OAAO,CAACL,IAAI,CAACC,OAAO,EAAE,EAAEM,OAAO,CAAC;EACtF;AACF;AAAC"}
1
+ {"version":3,"names":["EnumDeclarationTransformer","predicate","node","kind","ts","SyntaxKind","EnumDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","transform","enumDec","context","members","pMapSeries","member","memberName","memberSignature","getQuickInfoDisplayString","memberDoc","jsDocToDocSchema","memberLocation","getLocation","memberValue","initializer","EnumMemberSchema","signature","doc","EnumSchema"],"sources":["enum-declaration.ts"],"sourcesContent":["import ts, { Node, EnumDeclaration } from 'typescript';\nimport { EnumMemberSchema, EnumSchema } from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\n\nexport class EnumDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.EnumDeclaration;\n }\n\n async getIdentifiers(node: EnumDeclaration): Promise<ExportIdentifier[]> {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(enumDec: EnumDeclaration, context: SchemaExtractorContext) {\n const name = enumDec.name.getText();\n const members = await pMapSeries(enumDec.members, async (member) => {\n const memberName = member.name.getText();\n const memberSignature = await context.getQuickInfoDisplayString(member);\n const memberDoc = await context.jsDocToDocSchema(member);\n const memberLocation = await context.getLocation(member);\n const memberValue = member.initializer?.getText();\n return new EnumMemberSchema(memberLocation, memberName, memberSignature, memberValue, memberDoc);\n });\n const signature = await context.getQuickInfoDisplayString(enumDec.name);\n const doc = await context.jsDocToDocSchema(enumDec);\n return new EnumSchema(context.getLocation(enumDec), name, members, signature, doc);\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,0BAA0B,CAA8B;EACnEC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACC,eAAe;EACpD;EAEA,MAAMC,cAAc,CAACL,IAAqB,EAA+B;IACvE,OAAO,CAAC,KAAIM,oCAAgB,EAACN,IAAI,CAACO,IAAI,CAACC,OAAO,EAAE,EAAER,IAAI,CAACS,aAAa,EAAE,CAACC,QAAQ,CAAC,CAAC;EACnF;EAEA,MAAMC,SAAS,CAACC,OAAwB,EAAEC,OAA+B,EAAE;IACzE,MAAMN,IAAI,GAAGK,OAAO,CAACL,IAAI,CAACC,OAAO,EAAE;IACnC,MAAMM,OAAO,GAAG,MAAM,IAAAC,qBAAU,EAACH,OAAO,CAACE,OAAO,EAAE,MAAOE,MAAM,IAAK;MAAA;MAClE,MAAMC,UAAU,GAAGD,MAAM,CAACT,IAAI,CAACC,OAAO,EAAE;MACxC,MAAMU,eAAe,GAAG,MAAML,OAAO,CAACM,yBAAyB,CAACH,MAAM,CAAC;MACvE,MAAMI,SAAS,GAAG,MAAMP,OAAO,CAACQ,gBAAgB,CAACL,MAAM,CAAC;MACxD,MAAMM,cAAc,GAAG,MAAMT,OAAO,CAACU,WAAW,CAACP,MAAM,CAAC;MACxD,MAAMQ,WAAW,0BAAGR,MAAM,CAACS,WAAW,wDAAlB,oBAAoBjB,OAAO,EAAE;MACjD,OAAO,KAAIkB,qCAAgB,EAACJ,cAAc,EAAEL,UAAU,EAAEC,eAAe,EAAEM,WAAW,EAAEJ,SAAS,CAAC;IAClG,CAAC,CAAC;IACF,MAAMO,SAAS,GAAG,MAAMd,OAAO,CAACM,yBAAyB,CAACP,OAAO,CAACL,IAAI,CAAC;IACvE,MAAMqB,GAAG,GAAG,MAAMf,OAAO,CAACQ,gBAAgB,CAACT,OAAO,CAAC;IACnD,OAAO,KAAIiB,+BAAU,EAAChB,OAAO,CAACU,WAAW,CAACX,OAAO,CAAC,EAAEL,IAAI,EAAEO,OAAO,EAAEa,SAAS,EAAEC,GAAG,CAAC;EACpF;AACF;AAAC"}
@@ -68,7 +68,7 @@ class ExportDeclaration {
68
68
  // e.g. `export { button1, button2 } as Composition from './button';
69
69
  if (exportClause.kind === _typescript().SyntaxKind.NamedExports) {
70
70
  const schemas = await namedExport(exportClause, context);
71
- return new (_semanticsEntities().Module)(context.getLocation(exportDec), schemas);
71
+ return new (_semanticsEntities().ModuleSchema)(context.getLocation(exportDec), schemas);
72
72
  }
73
73
  // e.g. `export * as Composition from './button';
74
74
  if (exportClause.kind === _typescript().SyntaxKind.NamespaceExport) {
@@ -124,7 +124,7 @@ async function namespaceExport(exportClause, exportDec, context) {
124
124
  return context.getTypeRefForExternalPath(namespace, filePath, context.getLocation(exportDec));
125
125
  }
126
126
  const result = await context.computeSchema(sourceFile);
127
- if (!(result instanceof _semanticsEntities().Module)) {
127
+ if (!(result instanceof _semanticsEntities().ModuleSchema)) {
128
128
  throw new Error(`expect result to be instance of Module`);
129
129
  }
130
130
  result.namespace = namespace;
@@ -1 +1 @@
1
- {"version":3,"names":["ExportDeclaration","predicate","node","kind","SyntaxKind","getIdentifiers","exportDec","context","exportClause","ts","NamedExports","elements","map","elm","ExportIdentifier","name","getText","getSourceFile","fileName","NamespaceExport","moduleSpecifier","getFileExports","transform","specifier","Error","sourceFile","getSourceFileFromNode","computeSchema","schemas","namedExport","Module","getLocation","namespaceExport","isSameNode","nodeA","nodeB","pos","end","Promise","all","element","exportSpecifierToSchemaNode","definitionInfo","UnresolvedSchema","definitionNode","definition","getTypeRefForExternalNode","parent","getLocationAsString","ExportSpecifier","namespace","filePath","getFilePathByNode","getSourceFileInsideComponent","getTypeRefForExternalPath","result"],"sources":["export-declaration.ts"],"sourcesContent":["import { SchemaNode, Module, UnresolvedSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, {\n Node,\n SyntaxKind,\n ExportDeclaration as ExportDeclarationNode,\n NamedExports,\n NamespaceExport,\n ExportSpecifier,\n} from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\n\nexport class ExportDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.ExportDeclaration;\n }\n\n async getIdentifiers(exportDec: ExportDeclarationNode, context: SchemaExtractorContext) {\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamedExports) {\n exportDec.exportClause as NamedExports;\n return exportDec.exportClause.elements.map((elm) => {\n return new ExportIdentifier(elm.name.getText(), elm.getSourceFile().fileName);\n });\n }\n\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamespaceExport) {\n return [new ExportIdentifier(exportDec.exportClause.name.getText(), exportDec.getSourceFile().fileName)];\n }\n\n if (exportDec.moduleSpecifier) {\n return context.getFileExports(exportDec);\n }\n\n return [];\n }\n\n async transform(exportDec: ExportDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const exportClause = exportDec.exportClause;\n\n // it's export-all, e.g. `export * from './button'`;\n if (!exportClause) {\n const specifier = exportDec.moduleSpecifier;\n if (!specifier) {\n throw new Error(`fatal: no specifier`);\n }\n const sourceFile = await context.getSourceFileFromNode(specifier);\n if (!sourceFile) {\n throw new Error(`unable to find the source-file`);\n }\n return context.computeSchema(sourceFile);\n }\n\n // e.g. `export { button1, button2 } as Composition from './button';\n if (exportClause.kind === SyntaxKind.NamedExports) {\n const schemas = await namedExport(exportClause, context);\n return new Module(context.getLocation(exportDec), schemas);\n }\n // e.g. `export * as Composition from './button';\n if (exportClause.kind === SyntaxKind.NamespaceExport) {\n return namespaceExport(exportClause, exportDec, context);\n }\n\n // should never reach here. exportClause can be either NamespaceExport or NamedExports\n throw new Error(`unrecognized exportClause type`);\n }\n}\n\nfunction isSameNode(nodeA: Node, nodeB: Node): boolean {\n return nodeA.kind === nodeB.kind && nodeA.pos === nodeB.pos && nodeA.end === nodeB.end;\n}\n\nasync function namedExport(exportClause: NamedExports, context: SchemaExtractorContext): Promise<SchemaNode[]> {\n const schemas = await Promise.all(\n exportClause.elements.map(async (element) => {\n return exportSpecifierToSchemaNode(element, context);\n })\n );\n\n return schemas;\n}\n\nasync function exportSpecifierToSchemaNode(element: ExportSpecifier, context: SchemaExtractorContext) {\n const definitionInfo = await context.definitionInfo(element);\n\n if (!definitionInfo) {\n // happens for example when the main index.ts file exports variable from an mdx file.\n // tsserver is unable to get the definition node because it doesn't know to parse mdx files.\n return new UnresolvedSchema(context.getLocation(element.name), element.name.getText());\n }\n\n const definitionNode = await context.definition(definitionInfo);\n\n if (!definitionNode) {\n return context.getTypeRefForExternalNode(element);\n }\n\n // if it is reexported from another export\n if (isSameNode(element, definitionNode.parent)) {\n // the definition node is the same node as element.name. tsserver wasn't able to find the source for it\n // normally, \"bit install\" should fix it. another option is to open vscode and look for errors.\n throw new Error(`error: tsserver is unable to locate the identifier \"${element.name.getText()}\" at ${context.getLocationAsString(\n element.name\n )}.\nmake sure \"bit status\" is clean and there are no errors about missing packages/links.\nalso, make sure the tsconfig.json in the root has the \"jsx\" setting defined.`);\n }\n\n if (definitionNode.parent.kind === SyntaxKind.ExportSpecifier)\n return exportSpecifierToSchemaNode(definitionNode.parent as ExportSpecifier, context);\n\n return context.computeSchema(definitionNode.parent);\n}\n\nasync function namespaceExport(\n exportClause: NamespaceExport,\n exportDec: ExportDeclarationNode,\n context: SchemaExtractorContext\n) {\n const namespace = exportClause.name.getText();\n const filePath = await context.getFilePathByNode(exportClause.name);\n if (!filePath) {\n throw new Error(`unable to find the file-path for \"${namespace}\"`);\n }\n const sourceFile = context.getSourceFileInsideComponent(filePath);\n if (!sourceFile) {\n // it's a namespace from another component or an external package.\n return context.getTypeRefForExternalPath(namespace, filePath, context.getLocation(exportDec));\n }\n const result = await context.computeSchema(sourceFile);\n if (!(result instanceof Module)) {\n throw new Error(`expect result to be instance of Module`);\n }\n result.namespace = namespace;\n return result;\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAUA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAwD;AAAA;AAEjD,MAAMA,iBAAiB,CAA8B;EAC1DC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,wBAAU,CAACJ,iBAAiB;EACnD;EAEA,MAAMK,cAAc,CAACC,SAAgC,EAAEC,OAA+B,EAAE;IAAA;IACtF,IAAI,0BAAAD,SAAS,CAACE,YAAY,0DAAtB,sBAAwBL,IAAI,MAAKM,qBAAE,CAACL,UAAU,CAACM,YAAY,EAAE;MAC/DJ,SAAS,CAAC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AE,wCAAuC,CAAC;EAC3D;EACA+B,MAAM,CAACL,SAAS,GAAGA,SAAS;EAC5B,OAAOK,MAAM;AACf"}
1
+ {"version":3,"names":["ExportDeclaration","predicate","node","kind","SyntaxKind","getIdentifiers","exportDec","context","exportClause","ts","NamedExports","elements","map","elm","ExportIdentifier","name","getText","getSourceFile","fileName","NamespaceExport","moduleSpecifier","getFileExports","transform","specifier","Error","sourceFile","getSourceFileFromNode","computeSchema","schemas","namedExport","ModuleSchema","getLocation","namespaceExport","isSameNode","nodeA","nodeB","pos","end","Promise","all","element","exportSpecifierToSchemaNode","definitionInfo","UnresolvedSchema","definitionNode","definition","getTypeRefForExternalNode","parent","getLocationAsString","ExportSpecifier","namespace","filePath","getFilePathByNode","getSourceFileInsideComponent","getTypeRefForExternalPath","result"],"sources":["export-declaration.ts"],"sourcesContent":["import { SchemaNode, ModuleSchema, UnresolvedSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, {\n Node,\n SyntaxKind,\n ExportDeclaration as ExportDeclarationNode,\n NamedExports,\n NamespaceExport,\n ExportSpecifier,\n} from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\n\nexport class ExportDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.ExportDeclaration;\n }\n\n async getIdentifiers(exportDec: ExportDeclarationNode, context: SchemaExtractorContext) {\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamedExports) {\n exportDec.exportClause as NamedExports;\n return exportDec.exportClause.elements.map((elm) => {\n return new ExportIdentifier(elm.name.getText(), elm.getSourceFile().fileName);\n });\n }\n\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamespaceExport) {\n return [new ExportIdentifier(exportDec.exportClause.name.getText(), exportDec.getSourceFile().fileName)];\n }\n\n if (exportDec.moduleSpecifier) {\n return context.getFileExports(exportDec);\n }\n\n return [];\n }\n\n async transform(exportDec: ExportDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const exportClause = exportDec.exportClause;\n\n // it's export-all, e.g. `export * from './button'`;\n if (!exportClause) {\n const specifier = exportDec.moduleSpecifier;\n if (!specifier) {\n throw new Error(`fatal: no specifier`);\n }\n const sourceFile = await context.getSourceFileFromNode(specifier);\n if (!sourceFile) {\n throw new Error(`unable to find the source-file`);\n }\n return context.computeSchema(sourceFile);\n }\n\n // e.g. `export { button1, button2 } as Composition from './button';\n if (exportClause.kind === SyntaxKind.NamedExports) {\n const schemas = await namedExport(exportClause, context);\n return new ModuleSchema(context.getLocation(exportDec), schemas);\n }\n // e.g. `export * as Composition from './button';\n if (exportClause.kind === SyntaxKind.NamespaceExport) {\n return namespaceExport(exportClause, exportDec, context);\n }\n\n // should never reach here. exportClause can be either NamespaceExport or NamedExports\n throw new Error(`unrecognized exportClause type`);\n }\n}\n\nfunction isSameNode(nodeA: Node, nodeB: Node): boolean {\n return nodeA.kind === nodeB.kind && nodeA.pos === nodeB.pos && nodeA.end === nodeB.end;\n}\n\nasync function namedExport(exportClause: NamedExports, context: SchemaExtractorContext): Promise<SchemaNode[]> {\n const schemas = await Promise.all(\n exportClause.elements.map(async (element) => {\n return exportSpecifierToSchemaNode(element, context);\n })\n );\n\n return schemas;\n}\n\nasync function exportSpecifierToSchemaNode(element: ExportSpecifier, context: SchemaExtractorContext) {\n const definitionInfo = await context.definitionInfo(element);\n\n if (!definitionInfo) {\n // happens for example when the main index.ts file exports variable from an mdx file.\n // tsserver is unable to get the definition node because it doesn't know to parse mdx files.\n return new UnresolvedSchema(context.getLocation(element.name), element.name.getText());\n }\n\n const definitionNode = await context.definition(definitionInfo);\n\n if (!definitionNode) {\n return context.getTypeRefForExternalNode(element);\n }\n\n // if it is reexported from another export\n if (isSameNode(element, definitionNode.parent)) {\n // the definition node is the same node as element.name. tsserver wasn't able to find the source for it\n // normally, \"bit install\" should fix it. another option is to open vscode and look for errors.\n throw new Error(`error: tsserver is unable to locate the identifier \"${element.name.getText()}\" at ${context.getLocationAsString(\n element.name\n )}.\nmake sure \"bit status\" is clean and there are no errors about missing packages/links.\nalso, make sure the tsconfig.json in the root has the \"jsx\" setting defined.`);\n }\n\n if (definitionNode.parent.kind === SyntaxKind.ExportSpecifier)\n return exportSpecifierToSchemaNode(definitionNode.parent as ExportSpecifier, context);\n\n return context.computeSchema(definitionNode.parent);\n}\n\nasync function namespaceExport(\n exportClause: NamespaceExport,\n exportDec: ExportDeclarationNode,\n context: SchemaExtractorContext\n) {\n const namespace = exportClause.name.getText();\n const filePath = await context.getFilePathByNode(exportClause.name);\n if (!filePath) {\n throw new Error(`unable to find the file-path for \"${namespace}\"`);\n }\n const sourceFile = context.getSourceFileInsideComponent(filePath);\n if (!sourceFile) {\n // it's a namespace from another component or an external package.\n return context.getTypeRefForExternalPath(namespace, filePath, context.getLocation(exportDec));\n }\n const result = await context.computeSchema(sourceFile);\n if (!(result instanceof ModuleSchema)) {\n throw new Error(`expect result to be instance of Module`);\n }\n result.namespace = namespace;\n return result;\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAUA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAwD;AAAA;AAEjD,MAAMA,iBAAiB,CAA8B;EAC1DC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,wBAAU,CAACJ,iBAAiB;EACnD;EAEA,MAAMK,cAAc,CAACC,SAAgC,EAAEC,OAA+B,EAAE;IAAA;IACtF,IAAI,0BAAAD,SAAS,CAACE,YAAY,0DAAtB,sBAAwBL,IAAI,MAAKM,qBAAE,CAACL,UAAU,CAACM,YAAY,EAAE;MAC/DJ,SAAS,CAACE,YAAY;MACtB,OAAOF,SAAS,CAACE,YAAY,CAACG,QAAQ,CAACC,GAAG,CAAEC,GAAG,IAAK;QAClD,OAAO,KAAIC,oCAAgB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VariableStatementTransformer } from './variable-statement';
4
4
  export { VariableDeclaration } from './variable-declaration';
5
5
  export { SourceFileTransformer } from './source-file-transformer';
6
6
  export { TypeAliasTransformer } from './type-alias';
7
- export { ClassDecelerationTransformer } from './class-deceleration';
7
+ export { ClassDeclarationTransformer } from './class-declaration';
8
8
  export { InterfaceDeclarationTransformer } from './interface-declaration';
9
9
  export { EnumDeclarationTransformer } from './enum-declaration';
10
10
  export { BindingElementTransformer } from './binding-element';