@teambit/typescript 1.0.256 → 1.0.258

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.
@@ -0,0 +1,7 @@
1
+ import * as compositions_0 from '/Users/giladshoham/Library/Caches/Bit/capsules/root/b5ea46ec3/teambit.typescript_typescript@1.0.258/dist/typescript.composition.js';
2
+ import * as overview_0 from '/Users/giladshoham/Library/Caches/Bit/capsules/root/b5ea46ec3/teambit.typescript_typescript@1.0.258/dist/typescript.docs.mdx';
3
+
4
+ export const compositions = [compositions_0];
5
+ export const overview = [overview_0];
6
+
7
+ export const compositions_metadata = {"compositions":[{"displayName":"Logo","identifier":"Logo"}]};
@@ -99,14 +99,20 @@ async function namedExport(exportClause, context) {
99
99
  async function exportSpecifierToSchemaNode(element, context) {
100
100
  try {
101
101
  const definitionInfo = await context.definitionInfo(element);
102
+ const name = element.propertyName?.getText() || element.name.getText();
103
+ const alias = element.propertyName ? element.name.getText() : undefined;
104
+ const location = context.getLocation(element.name);
102
105
  if (!definitionInfo) {
106
+ const exportNode = new (_semanticsEntities().UnresolvedSchema)(location, element.name.getText());
103
107
  // happens for example when the main index.ts file exports variable from an mdx file.
104
108
  // tsserver is unable to get the definition node because it doesn't know to parse mdx files.
105
- return new (_semanticsEntities().UnresolvedSchema)(context.getLocation(element.name), element.name.getText());
109
+ // return new UnresolvedSchema(context.getLocation(element.name), element.name.getText());
110
+ return new (_semanticsEntities().ExportSchema)(location, name, exportNode, alias);
106
111
  }
107
112
  const definitionNode = await context.definition(definitionInfo);
108
113
  if (!definitionNode) {
109
- return await context.resolveType(element, element.name.getText(), false);
114
+ const exportNode = await context.resolveType(element, name, false);
115
+ return new (_semanticsEntities().ExportSchema)(location, name, exportNode, alias);
110
116
  }
111
117
 
112
118
  // if it is reexported from another export
@@ -117,10 +123,14 @@ async function exportSpecifierToSchemaNode(element, context) {
117
123
  make sure "bit status" is clean and there are no errors about missing packages/links.
118
124
  also, make sure the tsconfig.json in the root has the "jsx" setting defined.`);
119
125
  }
120
- if (definitionNode.parent.kind === _typescript().SyntaxKind.ExportSpecifier) return await exportSpecifierToSchemaNode(definitionNode.parent, context);
121
- return await context.computeSchema(definitionNode.parent);
126
+ if (definitionNode.parent.kind === _typescript().SyntaxKind.ExportSpecifier) {
127
+ return await exportSpecifierToSchemaNode(definitionNode.parent, context);
128
+ }
129
+ const exportNode = await context.computeSchema(definitionNode.parent);
130
+ return new (_semanticsEntities().ExportSchema)(location, name, exportNode, alias);
122
131
  } catch (e) {
123
- return new (_semanticsEntities().UnresolvedSchema)(context.getLocation(element.name), element.name.getText());
132
+ const exportNode = new (_semanticsEntities().UnresolvedSchema)(context.getLocation(element.name), element.name.getText());
133
+ return new (_semanticsEntities().ExportSchema)(context.getLocation(element.name), element.name.getText(), exportNode);
124
134
  }
125
135
  }
126
136
  async function namespaceExport(exportClause, exportDec, context) {
@@ -1 +1 @@
1
- {"version":3,"names":["_semanticsEntities","data","require","_typescript","_interopRequireWildcard","_exportIdentifier","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","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","exports","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 try {\n const definitionInfo = await context.definitionInfo(element);\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 await 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 await exportSpecifierToSchemaNode(definitionNode.parent as ExportSpecifier, context);\n\n return await context.computeSchema(definitionNode.parent);\n } catch (e) {\n return new UnresolvedSchema(context.getLocation(element.name), element.name.getText());\n }\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,SAAAA,mBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,kBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAMA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAG,uBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAUA,SAAAI,kBAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,iBAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAwD,SAAAK,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IA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OAAO,KAAIyE,qCAAgB,EAAC9C,OAAO,CAAC6B,WAAW,CAACc,OAAO,CAAC5B,IAAI,CAAC,EAAE4B,OAAO,CAAC5B,IAAI,CAACZ,OAAO,CAAC,CAAC,CAAC;EACxF;AACF;AAEA,eAAe+B,eAAeA,CAC5B3B,YAA6B,EAC7BR,SAAgC,EAChCC,OAA+B,EAC/B;EACA,MAAMqD,SAAS,GAAG9C,YAAY,CAACQ,IAAI,CAACZ,OAAO,CAAC,CAAC;EAC7C,MAAMmD,QAAQ,GAAG,MAAMtD,OAAO,CAACuD,iBAAiB,CAAChD,YAAY,CAACQ,IAAI,CAAC;EACnE,IAAI,CAACuC,QAAQ,EAAE;IACb,MAAM,IAAI7B,KAAK,CAAE,qCAAoC4B,SAAU,GAAE,CAAC;EACpE;EACA,MAAM3B,UAAU,GAAG1B,OAAO,CAACwD,4BAA4B,CAACF,QAAQ,CAAC;EACjE,IAAI,CAAC5B,UAAU,EAAE;IACf;IACA,OAAO1B,OAAO,CAACyD,yBAAyB,CAACJ,SAAS,EAAEC,QAAQ,EAAEtD,OAAO,CAAC6B,WAAW,CAAC9B,SAAS,CAAC,CAAC;EAC/F;EACA,MAAM2D,MAAM,GAAG,MAAM1D,OAAO,CAAC8B,aAAa,CAACJ,UAAU,CAAC;EACtD,IAAI,EAAEgC,MAAM,YAAYzB,iCAAY,CAAC,EAAE;IACrC,MAAM,IAAIR,KAAK,CAAE,wCAAuC,CAAC;EAC3D;EACAiC,MAAM,CAACL,SAAS,GAAGA,SAAS;EAC5B,OAAOK,MAAM;AACf","ignoreList":[]}
1
+ {"version":3,"names":["_semanticsEntities","data","require","_typescript","_interopRequireWildcard","_exportIdentifier","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","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","exports","isSameNode","nodeA","nodeB","pos","end","Promise","all","element","exportSpecifierToSchemaNode","definitionInfo","location","exportNode","UnresolvedSchema","ExportSchema","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 ExportSchema,\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<ExportSchema[]> {\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(\n element: ExportSpecifier,\n context: SchemaExtractorContext\n): Promise<ExportSchema> {\n try {\n const definitionInfo = await context.definitionInfo(element);\n const name = element.propertyName?.getText() || element.name.getText();\n const alias = element.propertyName ? element.name.getText() : undefined;\n const location = context.getLocation(element.name);\n\n if (!definitionInfo) {\n const exportNode = new UnresolvedSchema(location, element.name.getText());\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 return new ExportSchema(location, name, exportNode, alias);\n }\n\n const definitionNode = await context.definition(definitionInfo);\n\n if (!definitionNode) {\n const exportNode = await context.resolveType(element, name, false);\n return new ExportSchema(location, name, exportNode, alias);\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 await exportSpecifierToSchemaNode(definitionNode.parent as ExportSpecifier, context);\n }\n\n const exportNode = await context.computeSchema(definitionNode.parent);\n return new ExportSchema(location, name, exportNode, alias);\n } catch (e) {\n const exportNode = new UnresolvedSchema(context.getLocation(element.name), element.name.getText());\n return new ExportSchema(context.getLocation(element.name), element.name.getText(), exportNode);\n }\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 inst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12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/typescript",
3
- "version": "1.0.256",
3
+ "version": "1.0.258",
4
4
  "homepage": "https://bit.cloud/teambit/typescript/typescript",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.typescript",
8
8
  "name": "typescript",
9
- "version": "1.0.256"
9
+ "version": "1.0.258"
10
10
  },
11
11
  "dependencies": {
12
12
  "lodash": "4.17.21",
@@ -19,24 +19,24 @@
19
19
  "get-tsconfig": "4.2.0",
20
20
  "@teambit/typescript.typescript-compiler": "2.0.22",
21
21
  "@teambit/harmony": "0.4.6",
22
- "@teambit/compiler": "1.0.256",
22
+ "@teambit/compiler": "1.0.258",
23
23
  "@teambit/typescript.modules.ts-config-mutator": "0.0.83",
24
- "@teambit/builder": "1.0.256",
25
- "@teambit/isolator": "1.0.256",
26
- "@teambit/component": "1.0.256",
27
- "@teambit/dependency-resolver": "1.0.256",
28
- "@teambit/formatter": "1.0.256",
29
- "@teambit/semantics.entities.semantic-schema": "0.0.68",
24
+ "@teambit/builder": "1.0.258",
25
+ "@teambit/isolator": "1.0.258",
26
+ "@teambit/component": "1.0.258",
27
+ "@teambit/dependency-resolver": "1.0.258",
28
+ "@teambit/formatter": "1.0.258",
29
+ "@teambit/semantics.entities.semantic-schema": "0.0.69",
30
30
  "@teambit/ts-server": "0.0.56",
31
- "@teambit/aspect-loader": "1.0.256",
32
- "@teambit/envs": "1.0.256",
31
+ "@teambit/aspect-loader": "1.0.258",
32
+ "@teambit/envs": "1.0.258",
33
33
  "@teambit/logger": "0.0.955",
34
- "@teambit/workspace": "1.0.256",
35
- "@teambit/schema": "1.0.256",
36
- "@teambit/scope": "1.0.256",
34
+ "@teambit/workspace": "1.0.258",
35
+ "@teambit/schema": "1.0.258",
36
+ "@teambit/scope": "1.0.258",
37
37
  "@teambit/cli": "0.0.862",
38
- "@teambit/pkg": "1.0.256",
39
- "@teambit/watcher": "1.0.256"
38
+ "@teambit/pkg": "1.0.258",
39
+ "@teambit/watcher": "1.0.258"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/chai": "4.2.15",
@@ -3,6 +3,7 @@ import {
3
3
  ModuleSchema,
4
4
  UnresolvedSchema,
5
5
  UnImplementedSchema,
6
+ ExportSchema,
6
7
  } from '@teambit/semantics.entities.semantic-schema';
7
8
  import ts, {
8
9
  Node,
@@ -97,7 +98,7 @@ function isSameNode(nodeA: Node, nodeB: Node): boolean {
97
98
  return nodeA.kind === nodeB.kind && nodeA.pos === nodeB.pos && nodeA.end === nodeB.end;
98
99
  }
99
100
 
100
- async function namedExport(exportClause: NamedExports, context: SchemaExtractorContext): Promise<SchemaNode[]> {
101
+ async function namedExport(exportClause: NamedExports, context: SchemaExtractorContext): Promise<ExportSchema[]> {
101
102
  const schemas = await Promise.all(
102
103
  exportClause.elements.map(async (element) => {
103
104
  return exportSpecifierToSchemaNode(element, context);
@@ -107,19 +108,29 @@ async function namedExport(exportClause: NamedExports, context: SchemaExtractorC
107
108
  return schemas;
108
109
  }
109
110
 
110
- async function exportSpecifierToSchemaNode(element: ExportSpecifier, context: SchemaExtractorContext) {
111
+ async function exportSpecifierToSchemaNode(
112
+ element: ExportSpecifier,
113
+ context: SchemaExtractorContext
114
+ ): Promise<ExportSchema> {
111
115
  try {
112
116
  const definitionInfo = await context.definitionInfo(element);
117
+ const name = element.propertyName?.getText() || element.name.getText();
118
+ const alias = element.propertyName ? element.name.getText() : undefined;
119
+ const location = context.getLocation(element.name);
120
+
113
121
  if (!definitionInfo) {
122
+ const exportNode = new UnresolvedSchema(location, element.name.getText());
114
123
  // happens for example when the main index.ts file exports variable from an mdx file.
115
124
  // tsserver is unable to get the definition node because it doesn't know to parse mdx files.
116
- return new UnresolvedSchema(context.getLocation(element.name), element.name.getText());
125
+ // return new UnresolvedSchema(context.getLocation(element.name), element.name.getText());
126
+ return new ExportSchema(location, name, exportNode, alias);
117
127
  }
118
128
 
119
129
  const definitionNode = await context.definition(definitionInfo);
120
130
 
121
131
  if (!definitionNode) {
122
- return await context.resolveType(element, element.name.getText(), false);
132
+ const exportNode = await context.resolveType(element, name, false);
133
+ return new ExportSchema(location, name, exportNode, alias);
123
134
  }
124
135
 
125
136
  // if it is reexported from another export
@@ -133,12 +144,15 @@ make sure "bit status" is clean and there are no errors about missing packages/l
133
144
  also, make sure the tsconfig.json in the root has the "jsx" setting defined.`);
134
145
  }
135
146
 
136
- if (definitionNode.parent.kind === SyntaxKind.ExportSpecifier)
147
+ if (definitionNode.parent.kind === SyntaxKind.ExportSpecifier) {
137
148
  return await exportSpecifierToSchemaNode(definitionNode.parent as ExportSpecifier, context);
149
+ }
138
150
 
139
- return await context.computeSchema(definitionNode.parent);
151
+ const exportNode = await context.computeSchema(definitionNode.parent);
152
+ return new ExportSchema(location, name, exportNode, alias);
140
153
  } catch (e) {
141
- return new UnresolvedSchema(context.getLocation(element.name), element.name.getText());
154
+ const exportNode = new UnresolvedSchema(context.getLocation(element.name), element.name.getText());
155
+ return new ExportSchema(context.getLocation(element.name), element.name.getText(), exportNode);
142
156
  }
143
157
  }
144
158
 
@@ -1,7 +0,0 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.typescript_typescript@1.0.256/dist/typescript.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.typescript_typescript@1.0.256/dist/typescript.docs.mdx';
3
-
4
- export const compositions = [compositions_0];
5
- export const overview = [overview_0];
6
-
7
- export const compositions_metadata = {"compositions":[{"displayName":"Logo","identifier":"Logo"}]};