@teambit/typescript 1.0.257 → 1.0.259
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.
- package/artifacts/__bit_junit.xml +12 -12
- package/artifacts/preview/teambit_typescript_typescript-preview.js +1 -1
- package/artifacts/schema.json +6094 -5887
- package/dist/{preview-1714360874807.js → preview-1714533890836.js} +2 -2
- package/dist/sourceFileTransformers/export.d.ts +1 -1
- package/dist/sourceFileTransformers/export.js.map +1 -1
- package/dist/sourceFileTransformers/expression-statement.d.ts +1 -1
- package/dist/sourceFileTransformers/expression-statement.js.map +1 -1
- package/dist/sourceFileTransformers/function.d.ts +1 -1
- package/dist/sourceFileTransformers/function.js.map +1 -1
- package/dist/sourceFileTransformers/import.d.ts +1 -1
- package/dist/sourceFileTransformers/import.js.map +1 -1
- package/dist/transformers/export-declaration.js +15 -5
- package/dist/transformers/export-declaration.js.map +1 -1
- package/dist/tsconfig-writer.js +4 -4
- package/dist/tsconfig-writer.js.map +1 -1
- package/package.json +18 -18
- package/sourceFileTransformers/export.ts +1 -1
- package/sourceFileTransformers/expression-statement.ts +1 -1
- package/sourceFileTransformers/function.ts +1 -1
- package/sourceFileTransformers/import.ts +1 -1
- package/transformers/export-declaration.ts +21 -7
|
@@ -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<
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
151
|
+
const exportNode = await context.computeSchema(definitionNode.parent);
|
|
152
|
+
return new ExportSchema(location, name, exportNode, alias);
|
|
140
153
|
} catch (e) {
|
|
141
|
-
|
|
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
|
|