@teambit/typescript 0.0.965 → 0.0.967

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 (204) hide show
  1. package/dist/export-identifier.d.ts +5 -4
  2. package/dist/export-identifier.js +23 -4
  3. package/dist/export-identifier.js.map +1 -1
  4. package/dist/identifier-list.d.ts +7 -0
  5. package/dist/identifier-list.js +21 -0
  6. package/dist/identifier-list.js.map +1 -0
  7. package/dist/identifier.d.ts +9 -0
  8. package/dist/identifier.js +30 -0
  9. package/dist/identifier.js.map +1 -0
  10. package/dist/{preview-1674271762484.js → preview-1674617375675.js} +2 -2
  11. package/dist/schema-extractor-context.d.ts +40 -8
  12. package/dist/schema-extractor-context.js +243 -101
  13. package/dist/schema-extractor-context.js.map +1 -1
  14. package/dist/schema-transformer.d.ts +2 -2
  15. package/dist/schema-transformer.js.map +1 -1
  16. package/dist/transformers/array-type.d.ts +10 -0
  17. package/dist/transformers/array-type.js +38 -0
  18. package/dist/transformers/array-type.js.map +1 -0
  19. package/dist/transformers/binding-element.d.ts +2 -2
  20. package/dist/transformers/binding-element.js +7 -7
  21. package/dist/transformers/binding-element.js.map +1 -1
  22. package/dist/transformers/class-declaration.d.ts +2 -2
  23. package/dist/transformers/class-declaration.js +6 -20
  24. package/dist/transformers/class-declaration.js.map +1 -1
  25. package/dist/transformers/conditional-type.d.ts +10 -0
  26. package/dist/transformers/conditional-type.js +39 -0
  27. package/dist/transformers/conditional-type.js.map +1 -0
  28. package/dist/transformers/constructor.d.ts +10 -0
  29. package/dist/transformers/constructor.js +50 -0
  30. package/dist/transformers/constructor.js.map +1 -0
  31. package/dist/transformers/enum-declaration.d.ts +2 -2
  32. package/dist/transformers/enum-declaration.js +4 -4
  33. package/dist/transformers/enum-declaration.js.map +1 -1
  34. package/dist/transformers/{export-assignment-declaration.d.ts → export-assignment.d.ts} +7 -2
  35. package/dist/transformers/export-assignment.js +41 -0
  36. package/dist/transformers/export-assignment.js.map +1 -0
  37. package/dist/transformers/export-declaration.d.ts +2 -3
  38. package/dist/transformers/export-declaration.js +21 -10
  39. package/dist/transformers/export-declaration.js.map +1 -1
  40. package/dist/transformers/function-like.d.ts +11 -0
  41. package/dist/transformers/function-like.js +82 -0
  42. package/dist/transformers/function-like.js.map +1 -0
  43. package/dist/transformers/get-accessor.d.ts +10 -0
  44. package/dist/transformers/get-accessor.js +48 -0
  45. package/dist/transformers/get-accessor.js.map +1 -0
  46. package/dist/transformers/import-declaration.d.ts +10 -0
  47. package/dist/transformers/import-declaration.js +74 -0
  48. package/dist/transformers/import-declaration.js.map +1 -0
  49. package/dist/transformers/index-signature.d.ts +10 -0
  50. package/dist/transformers/index-signature.js +45 -0
  51. package/dist/transformers/index-signature.js.map +1 -0
  52. package/dist/transformers/index.d.ts +28 -3
  53. package/dist/transformers/index.js +337 -12
  54. package/dist/transformers/index.js.map +1 -1
  55. package/dist/transformers/indexed-access-type.d.ts +10 -0
  56. package/dist/transformers/indexed-access-type.js +37 -0
  57. package/dist/transformers/indexed-access-type.js.map +1 -0
  58. package/dist/transformers/interface-declaration.d.ts +2 -2
  59. package/dist/transformers/interface-declaration.js +6 -20
  60. package/dist/transformers/interface-declaration.js.map +1 -1
  61. package/dist/transformers/intersection-type.d.ts +10 -0
  62. package/dist/transformers/intersection-type.js +48 -0
  63. package/dist/transformers/intersection-type.js.map +1 -0
  64. package/dist/transformers/keyword-type.d.ts +13 -0
  65. package/dist/transformers/keyword-type.js +55 -0
  66. package/dist/transformers/keyword-type.js.map +1 -0
  67. package/dist/transformers/literal-type.d.ts +13 -0
  68. package/dist/transformers/literal-type.js +40 -0
  69. package/dist/transformers/literal-type.js.map +1 -0
  70. package/dist/transformers/named-tuple.d.ts +10 -0
  71. package/dist/transformers/named-tuple.js +38 -0
  72. package/dist/transformers/named-tuple.js.map +1 -0
  73. package/dist/transformers/parameter.d.ts +13 -0
  74. package/dist/transformers/parameter.js +112 -0
  75. package/dist/transformers/parameter.js.map +1 -0
  76. package/dist/transformers/parenthesized-type.d.ts +10 -0
  77. package/dist/transformers/parenthesized-type.js +36 -0
  78. package/dist/transformers/parenthesized-type.js.map +1 -0
  79. package/dist/transformers/property-declaration.d.ts +11 -0
  80. package/dist/transformers/property-declaration.js +57 -0
  81. package/dist/transformers/property-declaration.js.map +1 -0
  82. package/dist/transformers/set-accessor.d.ts +10 -0
  83. package/dist/transformers/set-accessor.js +45 -0
  84. package/dist/transformers/set-accessor.js.map +1 -0
  85. package/dist/transformers/source-file-transformer.d.ts +3 -2
  86. package/dist/transformers/source-file-transformer.js +44 -15
  87. package/dist/transformers/source-file-transformer.js.map +1 -1
  88. package/dist/transformers/template-literal-type-span.d.ts +10 -0
  89. package/dist/transformers/template-literal-type-span.js +37 -0
  90. package/dist/transformers/template-literal-type-span.js.map +1 -0
  91. package/dist/transformers/template-literal-type.d.ts +10 -0
  92. package/dist/transformers/template-literal-type.js +45 -0
  93. package/dist/transformers/template-literal-type.js.map +1 -0
  94. package/dist/transformers/this-type.d.ts +10 -0
  95. package/dist/transformers/this-type.js +35 -0
  96. package/dist/transformers/this-type.js.map +1 -0
  97. package/dist/transformers/tuple-type.d.ts +10 -0
  98. package/dist/transformers/tuple-type.js +47 -0
  99. package/dist/transformers/tuple-type.js.map +1 -0
  100. package/dist/transformers/type-alias.d.ts +2 -2
  101. package/dist/transformers/type-alias.js +5 -12
  102. package/dist/transformers/type-alias.js.map +1 -1
  103. package/dist/transformers/type-literal.d.ts +14 -0
  104. package/dist/transformers/type-literal.js +49 -0
  105. package/dist/transformers/type-literal.js.map +1 -0
  106. package/dist/transformers/type-operator.d.ts +14 -0
  107. package/dist/transformers/type-operator.js +52 -0
  108. package/dist/transformers/type-operator.js.map +1 -0
  109. package/dist/transformers/type-predicate.d.ts +10 -0
  110. package/dist/transformers/type-predicate.js +38 -0
  111. package/dist/transformers/type-predicate.js.map +1 -0
  112. package/dist/transformers/type-query.d.ts +13 -0
  113. package/dist/transformers/type-query.js +42 -0
  114. package/dist/transformers/type-query.js.map +1 -0
  115. package/dist/transformers/type-reference.d.ts +16 -0
  116. package/dist/transformers/type-reference.js +56 -0
  117. package/dist/transformers/type-reference.js.map +1 -0
  118. package/dist/transformers/union-type.d.ts +10 -0
  119. package/dist/transformers/union-type.js +48 -0
  120. package/dist/transformers/union-type.js.map +1 -0
  121. package/dist/transformers/utils/jsdoc-to-doc-schema.js +2 -10
  122. package/dist/transformers/utils/jsdoc-to-doc-schema.js.map +1 -1
  123. package/dist/transformers/variable-declaration.d.ts +2 -2
  124. package/dist/transformers/variable-declaration.js +11 -11
  125. package/dist/transformers/variable-declaration.js.map +1 -1
  126. package/dist/transformers/variable-statement.d.ts +2 -2
  127. package/dist/transformers/variable-statement.js +5 -5
  128. package/dist/transformers/variable-statement.js.map +1 -1
  129. package/dist/typescript.extractor.d.ts +10 -4
  130. package/dist/typescript.extractor.js +70 -17
  131. package/dist/typescript.extractor.js.map +1 -1
  132. package/dist/typescript.main.runtime.d.ts +4 -2
  133. package/dist/typescript.main.runtime.js +5 -11
  134. package/dist/typescript.main.runtime.js.map +1 -1
  135. package/package-tar/teambit-typescript-0.0.967.tgz +0 -0
  136. package/package.json +17 -17
  137. package/transformers/array-type.ts +21 -0
  138. package/transformers/binding-element.ts +2 -2
  139. package/transformers/class-declaration.ts +4 -6
  140. package/transformers/conditional-type.ts +23 -0
  141. package/transformers/constructor.ts +40 -0
  142. package/transformers/enum-declaration.ts +3 -3
  143. package/transformers/{export-assignment-declaration.ts → export-assignment.ts} +9 -3
  144. package/transformers/export-declaration.ts +35 -8
  145. package/transformers/function-like.ts +65 -0
  146. package/transformers/get-accessor.ts +24 -0
  147. package/transformers/import-declaration.ts +56 -0
  148. package/transformers/index-signature.ts +24 -0
  149. package/transformers/index.ts +28 -3
  150. package/transformers/indexed-access-type.ts +21 -0
  151. package/transformers/interface-declaration.ts +5 -7
  152. package/transformers/intersection-type.ts +25 -0
  153. package/transformers/keyword-type.ts +39 -0
  154. package/transformers/literal-type.ts +23 -0
  155. package/transformers/named-tuple.ts +22 -0
  156. package/transformers/parameter.ts +110 -0
  157. package/transformers/parenthesized-type.ts +20 -0
  158. package/transformers/property-declaration.ts +33 -0
  159. package/transformers/set-accessor.ts +25 -0
  160. package/transformers/source-file-transformer.ts +56 -24
  161. package/transformers/template-literal-type-span.ts +21 -0
  162. package/transformers/template-literal-type.ts +24 -0
  163. package/transformers/this-type.ts +19 -0
  164. package/transformers/tuple-type.ts +24 -0
  165. package/transformers/type-alias.ts +3 -4
  166. package/transformers/type-literal.ts +26 -0
  167. package/transformers/type-operator.ts +37 -0
  168. package/transformers/type-predicate.ts +22 -0
  169. package/transformers/type-query.ts +25 -0
  170. package/transformers/type-reference.ts +33 -0
  171. package/transformers/union-type.ts +25 -0
  172. package/transformers/utils/jsdoc-to-doc-schema.ts +2 -4
  173. package/transformers/variable-declaration.ts +7 -4
  174. package/transformers/variable-statement.ts +3 -3
  175. package/dist/export-list.d.ts +0 -6
  176. package/dist/export-list.js +0 -17
  177. package/dist/export-list.js.map +0 -1
  178. package/dist/transformers/export-assignment-declaration.js +0 -29
  179. package/dist/transformers/export-assignment-declaration.js.map +0 -1
  180. package/dist/transformers/function-declaration.d.ts +0 -11
  181. package/dist/transformers/function-declaration.js +0 -49
  182. package/dist/transformers/function-declaration.js.map +0 -1
  183. package/dist/transformers/utils/class-element-to-schema.d.ts +0 -4
  184. package/dist/transformers/utils/class-element-to-schema.js +0 -95
  185. package/dist/transformers/utils/class-element-to-schema.js.map +0 -1
  186. package/dist/transformers/utils/get-params.d.ts +0 -4
  187. package/dist/transformers/utils/get-params.js +0 -100
  188. package/dist/transformers/utils/get-params.js.map +0 -1
  189. package/dist/transformers/utils/to-function-like-schema.d.ts +0 -4
  190. package/dist/transformers/utils/to-function-like-schema.js +0 -58
  191. package/dist/transformers/utils/to-function-like-schema.js.map +0 -1
  192. package/dist/transformers/utils/type-element-to-schema.d.ts +0 -7
  193. package/dist/transformers/utils/type-element-to-schema.js +0 -106
  194. package/dist/transformers/utils/type-element-to-schema.js.map +0 -1
  195. package/dist/transformers/utils/type-node-to-schema.d.ts +0 -4
  196. package/dist/transformers/utils/type-node-to-schema.js +0 -274
  197. package/dist/transformers/utils/type-node-to-schema.js.map +0 -1
  198. package/package-tar/teambit-typescript-0.0.965.tgz +0 -0
  199. package/transformers/function-declaration.ts +0 -25
  200. package/transformers/utils/class-element-to-schema.ts +0 -64
  201. package/transformers/utils/get-params.ts +0 -92
  202. package/transformers/utils/to-function-like-schema.ts +0 -39
  203. package/transformers/utils/type-element-to-schema.ts +0 -79
  204. package/transformers/utils/type-node-to-schema.ts +0 -294
@@ -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","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,iB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wB,WAAW,CAACzB,SAAS,CAAC,CAAC;EAC/F;EACA,MAAMiD,MAAM,GAAG,MAAMhD,OAAO,CAACoB,aAAa,CAACF,UAAU,CAAC;EACtD,IAAI,EAAE8B,MAAM,YAAYzB,iCAAY,CAAC,EAAE;IACrC,MAAM,IAAIN,KAAK,CAAE,wCAAuC,CAAC;EAC3D;EACA+B,MAAM,CAACL,SAAS,GAAGA,SAAS;EAC5B,OAAOK,MAAM;AACf"}
1
+ {"version":3,"names":["ExportDeclarationTransformer","predicate","node","kind","SyntaxKind","ExportDeclaration","getIdentifiers","exportDec","context","rawSourceFilePath","moduleSpecifier","getText","sourceFilePath","substring","length","exportClause","ts","NamedExports","elements","map","elm","alias","propertyName","name","undefined","id","fileName","getSourceFile","ExportIdentifier","NamespaceExport","getFileExports","transform","specifier","Error","sourceFile","getSourceFileFromNode","UnImplementedSchema","getLocation","computeSchema","schemas","namedExport","ModuleSchema","namespaceExport","isSameNode","nodeA","nodeB","pos","end","Promise","all","element","exportSpecifierToSchemaNode","definitionInfo","UnresolvedSchema","definitionNode","definition","resolveType","parent","getLocationAsString","ExportSpecifier","namespace","filePath","getFilePathByNode","getSourceFileInsideComponent","getTypeRefForExternalPath","result"],"sources":["export-declaration.ts"],"sourcesContent":["import {\n SchemaNode,\n ModuleSchema,\n UnresolvedSchema,\n UnImplementedSchema,\n} 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 ExportDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.ExportDeclaration;\n }\n\n async getIdentifiers(exportDec: ExportDeclarationNode, context: SchemaExtractorContext) {\n // e.g. `export { button1, button2 } as Composition from './button';\n const rawSourceFilePath = exportDec.moduleSpecifier?.getText();\n\n // strip off quotes ''\n const sourceFilePath = rawSourceFilePath && rawSourceFilePath.substring(1, rawSourceFilePath?.length - 1);\n\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamedExports) {\n return exportDec.exportClause.elements.map((elm) => {\n const alias = (elm.propertyName && elm.name.getText()) || undefined;\n const id = elm.propertyName?.getText() || elm.name.getText();\n const fileName = elm.getSourceFile().fileName;\n\n return new ExportIdentifier(id, fileName, alias, sourceFilePath);\n });\n }\n\n // e.g. `export * as Composition from './button';\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamespaceExport) {\n return [\n new ExportIdentifier(\n exportDec.exportClause.name.getText(),\n exportDec.getSourceFile().fileName,\n undefined,\n sourceFilePath\n ),\n ];\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 // export * from 'webpack', export-all from a package\n if (!sourceFile) {\n return new UnImplementedSchema(\n context.getLocation(exportDec),\n exportDec.getText(),\n SyntaxKind[SyntaxKind.ExportDeclaration]\n );\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.resolveType(element, element.name.getText(), false);\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;AAMA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAUA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAwD;AAAA;AAEjD,MAAMA,4BAA4B,CAA8B;EACrEC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,wBAAU,CAACC,iBAAiB;EACnD;EAEA,MAAMC,cAAc,CAACC,SAAgC,EAAEC,OAA+B,EAAE;IAAA;IACtF;IACA,MAAMC,iBAAiB,4BAAGF,SAAS,CAACG,eAAe,0DAAzB,sBAA2BC,OAAO,EAAE;;IAE9D;IACA,MAAMC,cAAc,GAAGH,iBAAiB,IAAIA,iBAAiB,CAACI,SAAS,CAAC,CAAC,EAAE,CAAAJ,iBAAiB,aAAjBA,iBAAiB,uBAAjBA,iBAAiB,CAAEK,MAAM,IAAG,CAAC,CAAC;IAEzG,IAAI,0BAAAP,SAAS,CAACQ,YAAY,0DAAtB,sBAAwBZ,IAAI,MAAKa,qBAAE,CAACZ,UAAU,CAACa,YAAY,EAAE;MAC/D,OAAOV,SAAS,CAACQ,YAAY,CAACG,QAAQ,CAACC,GAAG,CAAEC,GAAG,IAAK;QAAA;QAClD,MAAMC,KAAK,GAAID,GAAG,CAACE,YAAY,IAAIF,GAAG,CAACG,IAAI,CAACZ,OAAO,EAAE,IAAKa,SAAS;QACnE,MAAMC,EAAE,GAAG,sBAAAL,GAAG,CAACE,YAAY,sDAAhB,kBAAkBX,OAAO,EAAE,KAAIS,GAAG,CAACG,IAAI,CAACZ,OAAO,EAAE;QAC5D,MAAMe,QAAQ,GAAGN,GAAG,CAACO,aAAa,EAAE,CAACD,QAAQ;QAE7C,OAAO,KAAIE,oCAAgB,EAACH,EAAE,EAAEC,QAAQ,EAAEL,KAAK,EAAET,cAAc,CAA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YAAYxB,iCAAY,CAAC,EAAE;IACrC,MAAM,IAAIR,KAAK,CAAE,wCAAuC,CAAC;EAC3D;EACAgC,MAAM,CAACL,SAAS,GAAGA,SAAS;EAC5B,OAAOK,MAAM;AACf"}
@@ -0,0 +1,11 @@
1
+ import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';
2
+ import { Node, SignatureDeclaration } from 'typescript';
3
+ import { SchemaExtractorContext } from '../schema-extractor-context';
4
+ import { SchemaTransformer } from '../schema-transformer';
5
+ import { Identifier } from '../identifier';
6
+ export declare class FunctionLikeTransformer implements SchemaTransformer {
7
+ predicate(node: Node): boolean;
8
+ getIdentifiers(funcDec: SignatureDeclaration): Promise<Identifier[]>;
9
+ private getName;
10
+ transform(node: SignatureDeclaration, context: SchemaExtractorContext): Promise<SchemaNode>;
11
+ }
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ require("core-js/modules/es.promise.js");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.FunctionLikeTransformer = void 0;
9
+ function _semanticsEntities() {
10
+ const data = require("@teambit/semantics.entities.semantic-schema");
11
+ _semanticsEntities = function () {
12
+ return data;
13
+ };
14
+ return data;
15
+ }
16
+ function _typescript() {
17
+ const data = _interopRequireDefault(require("typescript"));
18
+ _typescript = function () {
19
+ return data;
20
+ };
21
+ return data;
22
+ }
23
+ function _pMapSeries() {
24
+ const data = _interopRequireDefault(require("p-map-series"));
25
+ _pMapSeries = function () {
26
+ return data;
27
+ };
28
+ return data;
29
+ }
30
+ function _parseTypeFromQuickInfo() {
31
+ const data = require("./utils/parse-type-from-quick-info");
32
+ _parseTypeFromQuickInfo = function () {
33
+ return data;
34
+ };
35
+ return data;
36
+ }
37
+ function _identifier() {
38
+ const data = require("../identifier");
39
+ _identifier = function () {
40
+ return data;
41
+ };
42
+ return data;
43
+ }
44
+ class FunctionLikeTransformer {
45
+ predicate(node) {
46
+ return node.kind === _typescript().default.SyntaxKind.FunctionDeclaration || node.kind === _typescript().default.SyntaxKind.ArrowFunction || node.kind === _typescript().default.SyntaxKind.MethodDeclaration || node.kind === _typescript().default.SyntaxKind.CallSignature || node.kind === _typescript().default.SyntaxKind.ConstructSignature || node.kind === _typescript().default.SyntaxKind.IndexSignature || node.kind === _typescript().default.SyntaxKind.FunctionType || node.kind === _typescript().default.SyntaxKind.MethodSignature;
47
+ }
48
+
49
+ // need to check for anonymous functions assigned for vars, const and let.
50
+ async getIdentifiers(funcDec) {
51
+ return [new (_identifier().Identifier)(this.getName(funcDec), funcDec.getSourceFile().fileName)];
52
+ }
53
+ getName(funcDec) {
54
+ var _funcDec$name;
55
+ if (funcDec.kind === _typescript().default.SyntaxKind.ConstructSignature) return 'new';
56
+ return ((_funcDec$name = funcDec.name) === null || _funcDec$name === void 0 ? void 0 : _funcDec$name.getText()) || '';
57
+ }
58
+ async transform(node, context) {
59
+ var _info$body, _node$modifiers2, _node$typeParameters;
60
+ const name = this.getName(node);
61
+ const getQuickInfoFromDefaultModifier = async () => {
62
+ var _node$modifiers;
63
+ const defaultModifier = (_node$modifiers = node.modifiers) === null || _node$modifiers === void 0 ? void 0 : _node$modifiers.find(modifier => modifier.kind === _typescript().default.SyntaxKind.DefaultKeyword);
64
+ if (defaultModifier) return context.getQuickInfo(defaultModifier);
65
+ if (node.kind === _typescript().default.SyntaxKind.ArrowFunction) return context.getQuickInfo(node.equalsGreaterThanToken);
66
+ return null;
67
+ };
68
+ const info = node.name ? await context.getQuickInfo(node.name) : await getQuickInfoFromDefaultModifier();
69
+ const returnTypeStr = info ? (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info) : 'any';
70
+ const displaySig = (info === null || info === void 0 ? void 0 : (_info$body = info.body) === null || _info$body === void 0 ? void 0 : _info$body.displayString) || '';
71
+ const args = await (0, _pMapSeries().default)(node.parameters, async param => context.computeSchema(param));
72
+ const returnType = await context.resolveType(node, returnTypeStr, Boolean(info));
73
+ const modifiers = ((_node$modifiers2 = node.modifiers) === null || _node$modifiers2 === void 0 ? void 0 : _node$modifiers2.map(modifier => modifier.getText())) || [];
74
+ const typeParameters = (_node$typeParameters = node.typeParameters) === null || _node$typeParameters === void 0 ? void 0 : _node$typeParameters.map(typeParam => typeParam.name.getText());
75
+ const location = context.getLocation(node);
76
+ const doc = await context.jsDocToDocSchema(node);
77
+ return new (_semanticsEntities().FunctionLikeSchema)(location, name, args, returnType, displaySig, modifiers, doc, typeParameters);
78
+ }
79
+ }
80
+ exports.FunctionLikeTransformer = FunctionLikeTransformer;
81
+
82
+ //# sourceMappingURL=function-like.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["FunctionLikeTransformer","predicate","node","kind","ts","SyntaxKind","FunctionDeclaration","ArrowFunction","MethodDeclaration","CallSignature","ConstructSignature","IndexSignature","FunctionType","MethodSignature","getIdentifiers","funcDec","Identifier","getName","getSourceFile","fileName","name","getText","transform","context","getQuickInfoFromDefaultModifier","defaultModifier","modifiers","find","modifier","DefaultKeyword","getQuickInfo","equalsGreaterThanToken","info","returnTypeStr","parseTypeFromQuickInfo","displaySig","body","displayString","args","pMapSeries","parameters","param","computeSchema","returnType","resolveType","Boolean","map","typeParameters","typeParam","location","getLocation","doc","jsDocToDocSchema","FunctionLikeSchema"],"sources":["function-like.ts"],"sourcesContent":["import { FunctionLikeSchema, ParameterSchema, SchemaNode, Modifier } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, SignatureDeclaration } from 'typescript';\nimport pMapSeries from 'p-map-series';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\nimport { Identifier } from '../identifier';\n\nexport class FunctionLikeTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return (\n node.kind === ts.SyntaxKind.FunctionDeclaration ||\n node.kind === ts.SyntaxKind.ArrowFunction ||\n node.kind === ts.SyntaxKind.MethodDeclaration ||\n node.kind === ts.SyntaxKind.CallSignature ||\n node.kind === ts.SyntaxKind.ConstructSignature ||\n node.kind === ts.SyntaxKind.IndexSignature ||\n node.kind === ts.SyntaxKind.FunctionType ||\n node.kind === ts.SyntaxKind.MethodSignature\n );\n }\n\n // need to check for anonymous functions assigned for vars, const and let.\n async getIdentifiers(funcDec: SignatureDeclaration) {\n return [new Identifier(this.getName(funcDec), funcDec.getSourceFile().fileName)];\n }\n\n private getName(funcDec: SignatureDeclaration) {\n if (funcDec.kind === ts.SyntaxKind.ConstructSignature) return 'new';\n return funcDec.name?.getText() || '';\n }\n\n async transform(node: SignatureDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {\n const name = this.getName(node);\n const getQuickInfoFromDefaultModifier = async () => {\n const defaultModifier = node.modifiers?.find((modifier) => modifier.kind === ts.SyntaxKind.DefaultKeyword);\n if (defaultModifier) return context.getQuickInfo(defaultModifier);\n if (node.kind === ts.SyntaxKind.ArrowFunction) return context.getQuickInfo(node.equalsGreaterThanToken);\n return null;\n };\n const info = node.name ? await context.getQuickInfo(node.name) : await getQuickInfoFromDefaultModifier();\n const returnTypeStr = info ? parseTypeFromQuickInfo(info) : 'any';\n const displaySig = info?.body?.displayString || '';\n const args = (await pMapSeries(node.parameters, async (param) =>\n context.computeSchema(param)\n )) as ParameterSchema[];\n\n const returnType = await context.resolveType(node, returnTypeStr, Boolean(info));\n const modifiers = node.modifiers?.map((modifier) => modifier.getText()) || [];\n const typeParameters = node.typeParameters?.map((typeParam) => typeParam.name.getText());\n const location = context.getLocation(node);\n const doc = await context.jsDocToDocSchema(node);\n\n return new FunctionLikeSchema(\n location,\n name,\n args,\n returnType,\n displaySig,\n modifiers as Modifier[],\n doc,\n typeParameters\n );\n }\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AA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AEE,SAAS,IAAKA,SAAS,CAAC5B,IAAI,CAACC,OAAO,EAAE,CAAC;IACxF,MAAM4B,QAAQ,GAAG1B,OAAO,CAAC2B,WAAW,CAAChD,IAAI,CAAC;IAC1C,MAAMiD,GAAG,GAAG,MAAM5B,OAAO,CAAC6B,gBAAgB,CAAClD,IAAI,CAAC;IAEhD,OAAO,KAAImD,uCAAkB,EAC3BJ,QAAQ,EACR7B,IAAI,EACJkB,IAAI,EACJK,UAAU,EACVR,UAAU,EACVT,SAAS,EACTyB,GAAG,EACHJ,cAAc,CACf;EACH;AACF;AAAC"}
@@ -0,0 +1,10 @@
1
+ import { Node, GetAccessorDeclaration } from 'typescript';
2
+ import { GetAccessorSchema } from '@teambit/semantics.entities.semantic-schema';
3
+ import { SchemaTransformer } from '../schema-transformer';
4
+ import { SchemaExtractorContext } from '../schema-extractor-context';
5
+ import { Identifier } from '../identifier';
6
+ export declare class GetAccessorTransformer implements SchemaTransformer {
7
+ predicate(node: Node): boolean;
8
+ getIdentifiers(): Promise<Identifier[]>;
9
+ transform(node: GetAccessorDeclaration, context: SchemaExtractorContext): Promise<GetAccessorSchema>;
10
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ require("core-js/modules/es.promise.js");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.GetAccessorTransformer = void 0;
9
+ function _typescript() {
10
+ const data = _interopRequireDefault(require("typescript"));
11
+ _typescript = function () {
12
+ return data;
13
+ };
14
+ return data;
15
+ }
16
+ function _semanticsEntities() {
17
+ const data = require("@teambit/semantics.entities.semantic-schema");
18
+ _semanticsEntities = function () {
19
+ return data;
20
+ };
21
+ return data;
22
+ }
23
+ function _parseTypeFromQuickInfo() {
24
+ const data = require("./utils/parse-type-from-quick-info");
25
+ _parseTypeFromQuickInfo = function () {
26
+ return data;
27
+ };
28
+ return data;
29
+ }
30
+ class GetAccessorTransformer {
31
+ predicate(node) {
32
+ return node.kind === _typescript().default.SyntaxKind.GetAccessor;
33
+ }
34
+ async getIdentifiers() {
35
+ return [];
36
+ }
37
+ async transform(node, context) {
38
+ var _info$body;
39
+ const info = await context.getQuickInfo(node.name);
40
+ const displaySig = (info === null || info === void 0 ? void 0 : (_info$body = info.body) === null || _info$body === void 0 ? void 0 : _info$body.displayString) || '';
41
+ const typeStr = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
42
+ const type = await context.resolveType(node, typeStr);
43
+ return new (_semanticsEntities().GetAccessorSchema)(context.getLocation(node), node.name.getText(), type, displaySig);
44
+ }
45
+ }
46
+ exports.GetAccessorTransformer = GetAccessorTransformer;
47
+
48
+ //# sourceMappingURL=get-accessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["GetAccessorTransformer","predicate","node","kind","ts","SyntaxKind","GetAccessor","getIdentifiers","transform","context","info","getQuickInfo","name","displaySig","body","displayString","typeStr","parseTypeFromQuickInfo","type","resolveType","GetAccessorSchema","getLocation","getText"],"sources":["get-accessor.ts"],"sourcesContent":["import ts, { Node, GetAccessorDeclaration } from 'typescript';\nimport { GetAccessorSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\nimport { Identifier } from '../identifier';\n\nexport class GetAccessorTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.GetAccessor;\n }\n\n async getIdentifiers(): Promise<Identifier[]> {\n return [];\n }\n\n async transform(node: GetAccessorDeclaration, context: SchemaExtractorContext) {\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 return new GetAccessorSchema(context.getLocation(node), node.name.getText(), type, displaySig);\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;AAGO,MAAMA,sBAAsB,CAA8B;EAC/DC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACC,WAAW;EAChD;EAEA,MAAMC,cAAc,GAA0B;IAC5C,OAAO,EAAE;EACX;EAEA,MAAMC,SAAS,CAACN,IAA4B,EAAEO,OAA+B,EAAE;IAAA;IAC7E,MAAMC,IAAI,GAAG,MAAMD,OAAO,CAACE,YAAY,CAACT,IAAI,CAACU,IAAI,CAAC;IAClD,MAAMC,UAAU,GAAG,CAAAH,IAAI,aAAJA,IAAI,qCAAJA,IAAI,CAAEI,IAAI,+CAAV,WAAYC,aAAa,KAAI,EAAE;IAClD,MAAMC,OAAO,GAAG,IAAAC,gDAAsB,EAACP,IAAI,CAAC;IAC5C,MAAMQ,IAAI,GAAG,MAAMT,OAAO,CAACU,WAAW,CAACjB,IAAI,EAAEc,OAAO,CAAC;IACrD,OAAO,KAAII,sCAAiB,EAACX,OAAO,CAACY,WAAW,CAACnB,IAAI,CAAC,EAAEA,IAAI,CAACU,IAAI,CAACU,OAAO,EAAE,EAAEJ,IAAI,EAAEL,UAAU,CAAC;EAChG;AACF;AAAC"}
@@ -0,0 +1,10 @@
1
+ import { ImportDeclaration, Node } from 'typescript';
2
+ import { UnImplementedSchema } from '@teambit/semantics.entities.semantic-schema';
3
+ import { SchemaTransformer } from '../schema-transformer';
4
+ import { SchemaExtractorContext } from '../schema-extractor-context';
5
+ import { Identifier } from '../identifier';
6
+ export declare class ImportDeclarationTransformer implements SchemaTransformer {
7
+ predicate(node: Node): boolean;
8
+ getIdentifiers(importDec: ImportDeclaration): Promise<Identifier[]>;
9
+ transform(node: ImportDeclaration, context: SchemaExtractorContext): Promise<UnImplementedSchema>;
10
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.promise.js");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.ImportDeclarationTransformer = void 0;
8
+ function _typescript() {
9
+ const data = require("typescript");
10
+ _typescript = function () {
11
+ return data;
12
+ };
13
+ return data;
14
+ }
15
+ function _semanticsEntities() {
16
+ const data = require("@teambit/semantics.entities.semantic-schema");
17
+ _semanticsEntities = function () {
18
+ return data;
19
+ };
20
+ return data;
21
+ }
22
+ function _identifier() {
23
+ const data = require("../identifier");
24
+ _identifier = function () {
25
+ return data;
26
+ };
27
+ return data;
28
+ }
29
+ class ImportDeclarationTransformer {
30
+ predicate(node) {
31
+ return node.kind === _typescript().SyntaxKind.ImportDeclaration;
32
+ }
33
+ async getIdentifiers(importDec) {
34
+ var _importDec$importClau;
35
+ if (!importDec.importClause) return [];
36
+ const sourceFile = importDec.getSourceFile().fileName;
37
+ const rawSourceFilePath = importDec.moduleSpecifier.getText();
38
+ const sourceFilePath = rawSourceFilePath.substring(1, rawSourceFilePath.length - 1);
39
+
40
+ // import A from 'a'
41
+ if (!importDec.importClause.namedBindings) {
42
+ return [new (_identifier().Identifier)(importDec.importClause.getText(), sourceFile, undefined, sourceFilePath)];
43
+ }
44
+
45
+ // import { A } from 'a'
46
+ if (((_importDec$importClau = importDec.importClause.namedBindings) === null || _importDec$importClau === void 0 ? void 0 : _importDec$importClau.kind) === _typescript().SyntaxKind.NamedImports) {
47
+ const {
48
+ elements
49
+ } = importDec.importClause.namedBindings;
50
+ return elements.map(({
51
+ name,
52
+ propertyName
53
+ }) => {
54
+ const id = (propertyName === null || propertyName === void 0 ? void 0 : propertyName.getText()) || name.getText();
55
+ const alias = propertyName && name.getText() || undefined;
56
+ const identifier = new (_identifier().Identifier)(id, sourceFile, alias, sourceFilePath);
57
+ return identifier;
58
+ });
59
+ }
60
+
61
+ // import * as A from 'a';
62
+ if (importDec.importClause.namedBindings.kind === _typescript().SyntaxKind.NamespaceImport) {
63
+ return [new (_identifier().Identifier)(importDec.importClause.namedBindings.name.getText(), sourceFile, undefined, importDec.moduleSpecifier.getText())];
64
+ }
65
+ return [];
66
+ }
67
+ async transform(node, context) {
68
+ const location = context.getLocation(node);
69
+ return new (_semanticsEntities().UnImplementedSchema)(location, node.getText(), node.kind.toString());
70
+ }
71
+ }
72
+ exports.ImportDeclarationTransformer = ImportDeclarationTransformer;
73
+
74
+ //# sourceMappingURL=import-declaration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ImportDeclarationTransformer","predicate","node","kind","SyntaxKind","ImportDeclaration","getIdentifiers","importDec","importClause","sourceFile","getSourceFile","fileName","rawSourceFilePath","moduleSpecifier","getText","sourceFilePath","substring","length","namedBindings","Identifier","undefined","NamedImports","elements","map","name","propertyName","id","alias","identifier","NamespaceImport","transform","context","location","getLocation","UnImplementedSchema","toString"],"sources":["import-declaration.ts"],"sourcesContent":["import { ImportDeclaration, Node, SyntaxKind } from 'typescript';\nimport { UnImplementedSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { Identifier } from '../identifier';\n\nexport class ImportDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.ImportDeclaration;\n }\n\n async getIdentifiers(importDec: ImportDeclaration): Promise<Identifier[]> {\n if (!importDec.importClause) return [];\n\n const sourceFile = importDec.getSourceFile().fileName;\n const rawSourceFilePath = importDec.moduleSpecifier.getText();\n const sourceFilePath = rawSourceFilePath.substring(1, rawSourceFilePath.length - 1);\n\n // import A from 'a'\n if (!importDec.importClause.namedBindings) {\n return [new Identifier(importDec.importClause.getText(), sourceFile, undefined, sourceFilePath)];\n }\n\n // import { A } from 'a'\n if (importDec.importClause.namedBindings?.kind === SyntaxKind.NamedImports) {\n const { elements } = importDec.importClause.namedBindings;\n\n return elements.map(({ name, propertyName }) => {\n const id = propertyName?.getText() || name.getText();\n const alias = (propertyName && name.getText()) || undefined;\n const identifier = new Identifier(id, sourceFile, alias, sourceFilePath);\n return identifier;\n });\n }\n\n // import * as A from 'a';\n if (importDec.importClause.namedBindings.kind === SyntaxKind.NamespaceImport) {\n return [\n new Identifier(\n importDec.importClause.namedBindings.name.getText(),\n sourceFile,\n undefined,\n importDec.moduleSpecifier.getText()\n ),\n ];\n }\n\n return [];\n }\n\n async transform(node: ImportDeclaration, context: SchemaExtractorContext) {\n const location = context.getLocation(node);\n\n return new UnImplementedSchema(location, node.getText(), node.kind.toString());\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,4BAA4B,CAA8B;EACrEC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,wBAAU,CAACC,iBAAiB;EACnD;EAEA,MAAMC,cAAc,CAACC,SAA4B,EAAyB;IAAA;IACxE,IAAI,CAACA,SAAS,CAACC,YAAY,EAAE,OAAO,EAAE;IAEtC,MAAMC,UAAU,GAAGF,SAAS,CAACG,aAAa,EAAE,CAACC,QAAQ;IACrD,MAAMC,iBAAiB,GAAGL,SAAS,CAACM,eAAe,CAACC,OAAO,EAAE;IAC7D,MAAMC,cAAc,GAAGH,iBAAiB,CAACI,SAAS,CAAC,CAAC,EAAEJ,iBAAiB,CAACK,MAAM,GAAG,CAAC,CAAC;;IAEnF;IACA,IAAI,CAACV,SAAS,CAACC,YAAY,CAACU,aAAa,EAAE;MACzC,OAAO,CAAC,KAAIC,wBAAU,EAACZ,SAAS,CAACC,YAAY,CAACM,OAAO,EAAE,EAAEL,UAAU,EAAEW,SAAS,EAAEL,cAAc,CAAC,CAAC;IAClG;;IAEA;IACA,IAAI,0BAAAR,SAAS,CAACC,YAAY,CAACU,aAAa,0DAApC,sBAAsCf,IAAI,MAAKC,wBAAU,CAACiB,YAAY,EAAE;MAC1E,MAAM;QAAEC;MAAS,CAAC,GAAGf,SAAS,CAACC,YAAY,CAACU,aAAa;MAEzD,OAAOI,QAAQ,CAACC,GAAG,CAAC,CAAC;QAAEC,IAAI;QAAEC;MAAa,CAAC,KAAK;QAC9C,MAAMC,EAAE,GAAG,CAAAD,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEX,OAAO,EAAE,KAAIU,IAAI,CAACV,OAAO,EAAE;QACpD,MAAMa,KAAK,GAAIF,YAAY,IAAID,IAAI,CAACV,OAAO,EAAE,IAAKM,SAAS;QAC3D,MAAMQ,UAAU,GAAG,KAAIT,wBAAU,EAACO,EAAE,EAAEjB,UAAU,EAAEkB,KAAK,EAAEZ,cAAc,CAAC;QACxE,OAAOa,UAAU;MACnB,CAAC,CAAC;IACJ;;IAEA;IACA,IAAIrB,SAAS,CAACC,YAAY,CAACU,aAAa,CAACf,IAAI,KAAKC,wBAAU,CAACyB,eAAe,EAAE;MAC5E,OAAO,CACL,KAAIV,wBAAU,EACZZ,SAAS,CAACC,YAAY,CAACU,aAAa,CAACM,IAAI,CAACV,OAAO,EAAE,EACnDL,UAAU,EACVW,SAAS,EACTb,SAAS,CAACM,eAAe,CAACC,OAAO,EAAE,CACpC,CACF;IACH;IAEA,OAAO,EAAE;EACX;EAEA,MAAMgB,SAAS,CAAC5B,IAAuB,EAAE6B,OAA+B,EAAE;IACxE,MAAMC,QAAQ,GAAGD,OAAO,CAACE,WAAW,CAAC/B,IAAI,CAAC;IAE1C,OAAO,KAAIgC,wCAAmB,EAACF,QAAQ,EAAE9B,IAAI,CAACY,OAAO,EAAE,EAAEZ,IAAI,CAACC,IAAI,CAACgC,QAAQ,EAAE,CAAC;EAChF;AACF;AAAC"}
@@ -0,0 +1,10 @@
1
+ import { Node, IndexSignatureDeclaration } from 'typescript';
2
+ import { IndexSignatureSchema } from '@teambit/semantics.entities.semantic-schema';
3
+ import { SchemaTransformer } from '../schema-transformer';
4
+ import { SchemaExtractorContext } from '../schema-extractor-context';
5
+ import { Identifier } from '../identifier';
6
+ export declare class IndexSignatureTransformer implements SchemaTransformer {
7
+ predicate(node: Node): boolean;
8
+ getIdentifiers(): Promise<Identifier[]>;
9
+ transform(node: IndexSignatureDeclaration, context: SchemaExtractorContext): Promise<IndexSignatureSchema>;
10
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ require("core-js/modules/es.promise.js");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.IndexSignatureTransformer = void 0;
9
+ function _typescript() {
10
+ const data = _interopRequireDefault(require("typescript"));
11
+ _typescript = function () {
12
+ return data;
13
+ };
14
+ return data;
15
+ }
16
+ function _semanticsEntities() {
17
+ const data = require("@teambit/semantics.entities.semantic-schema");
18
+ _semanticsEntities = function () {
19
+ return data;
20
+ };
21
+ return data;
22
+ }
23
+ function _pMapSeries() {
24
+ const data = _interopRequireDefault(require("p-map-series"));
25
+ _pMapSeries = function () {
26
+ return data;
27
+ };
28
+ return data;
29
+ }
30
+ class IndexSignatureTransformer {
31
+ predicate(node) {
32
+ return node.kind === _typescript().default.SyntaxKind.IndexSignature;
33
+ }
34
+ async getIdentifiers() {
35
+ return [];
36
+ }
37
+ async transform(node, context) {
38
+ const params = await (0, _pMapSeries().default)(node.parameters, async param => context.computeSchema(param));
39
+ const type = await context.computeSchema(node.type);
40
+ return new (_semanticsEntities().IndexSignatureSchema)(context.getLocation(node), params, type);
41
+ }
42
+ }
43
+ exports.IndexSignatureTransformer = IndexSignatureTransformer;
44
+
45
+ //# sourceMappingURL=index-signature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["IndexSignatureTransformer","predicate","node","kind","ts","SyntaxKind","IndexSignature","getIdentifiers","transform","context","params","pMapSeries","parameters","param","computeSchema","type","IndexSignatureSchema","getLocation"],"sources":["index-signature.ts"],"sourcesContent":["import ts, { Node, IndexSignatureDeclaration } from 'typescript';\nimport { IndexSignatureSchema, ParameterSchema } from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { Identifier } from '../identifier';\n\nexport class IndexSignatureTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.IndexSignature;\n }\n\n async getIdentifiers(): Promise<Identifier[]> {\n return [];\n }\n\n async transform(node: IndexSignatureDeclaration, context: SchemaExtractorContext) {\n const params = (await pMapSeries(node.parameters, async (param) =>\n context.computeSchema(param)\n )) as ParameterSchema[];\n const type = await context.computeSchema(node.type);\n return new IndexSignatureSchema(context.getLocation(node), params, type);\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;AAKO,MAAMA,yBAAyB,CAA8B;EAClEC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACC,cAAc;EACnD;EAEA,MAAMC,cAAc,GAA0B;IAC5C,OAAO,EAAE;EACX;EAEA,MAAMC,SAAS,CAACN,IAA+B,EAAEO,OAA+B,EAAE;IAChF,MAAMC,MAAM,GAAI,MAAM,IAAAC,qBAAU,EAACT,IAAI,CAACU,UAAU,EAAE,MAAOC,KAAK,IAC5DJ,OAAO,CAACK,aAAa,CAACD,KAAK,CAAC,CACP;IACvB,MAAME,IAAI,GAAG,MAAMN,OAAO,CAACK,aAAa,CAACZ,IAAI,CAACa,IAAI,CAAC;IACnD,OAAO,KAAIC,yCAAoB,EAACP,OAAO,CAACQ,WAAW,CAACf,IAAI,CAAC,EAAEQ,MAAM,EAAEK,IAAI,CAAC;EAC1E;AACF;AAAC"}
@@ -1,11 +1,36 @@
1
- export { ExportDeclaration } from './export-declaration';
2
- export { FunctionDeclaration } from './function-declaration';
1
+ export { ExportDeclarationTransformer } from './export-declaration';
2
+ export { FunctionLikeTransformer } from './function-like';
3
+ export { ParameterTransformer } from './parameter';
3
4
  export { VariableStatementTransformer } from './variable-statement';
4
5
  export { VariableDeclaration } from './variable-declaration';
5
6
  export { SourceFileTransformer } from './source-file-transformer';
6
7
  export { TypeAliasTransformer } from './type-alias';
8
+ export { IntersectionTypeTransformer } from './intersection-type';
9
+ export { UnionTypeTransformer } from './union-type';
10
+ export { TypeReferenceTransformer } from './type-reference';
11
+ export { TypeLiteralTransformer } from './type-literal';
12
+ export { LiteralTypeTransformer } from './literal-type';
13
+ export { TypeQueryTransformer } from './type-query';
14
+ export { TypeOperatorTransformer } from './type-operator';
15
+ export { KeywordTypeTransformer } from './keyword-type';
16
+ export { TupleTypeTransformer } from './tuple-type';
17
+ export { ParenthesizedTypeTransformer } from './parenthesized-type';
18
+ export { TypePredicateTransformer } from './type-predicate';
19
+ export { IndexedAccessTypeTransformer } from './indexed-access-type';
20
+ export { TemplateLiteralTypeSpanTransformer } from './template-literal-type-span';
21
+ export { TemplateLiteralTypeTransformer } from './template-literal-type';
22
+ export { ThisTypeTransformer } from './this-type';
23
+ export { ConditionalTypeTransformer } from './conditional-type';
24
+ export { NamedTupleTransformer } from './named-tuple';
25
+ export { ArrayTypeTransformer } from './array-type';
7
26
  export { ClassDeclarationTransformer } from './class-declaration';
27
+ export { ConstructorTransformer } from './constructor';
28
+ export { PropertyDeclarationTransformer } from './property-declaration';
29
+ export { SetAccessorTransformer } from './set-accessor';
30
+ export { GetAccessorTransformer } from './get-accessor';
31
+ export { IndexSignatureTransformer } from './index-signature';
8
32
  export { InterfaceDeclarationTransformer } from './interface-declaration';
9
33
  export { EnumDeclarationTransformer } from './enum-declaration';
10
34
  export { BindingElementTransformer } from './binding-element';
11
- export { ExportAssignmentDeclaration } from './export-assignment-declaration';
35
+ export { ExportAssignmentTransformer } from './export-assignment';
36
+ export { ImportDeclarationTransformer } from './import-declaration';