mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-29 16:29:19 -05:00
Implement export as namespace from (#34903)
* init export start as decl * fix some broken * fix more case * fix more and more case * make it work * make lint happy and accept baseline * add more tests * fix system module * add more case * delete useless assert * accept baseline * make lint happy * fix missing utils * update api * make lint happy * add missing semi * fix minor issue * fix locally bound * avoid useless check * update public api * add more case * fix some case * Use multi-module selection in test runner to cut down on duplication. * Accepted baselines. * remove superfluous tests. * Remove baseline. * Downlevel `export * as ns` in es2015. * Accepted baselines. * Update names of things. Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
This commit is contained in:
committed by
Daniel Rosenwasser
parent
2f0d07c29a
commit
4c7844be74
@@ -240,7 +240,9 @@ namespace ts.FindAllReferences {
|
||||
}
|
||||
|
||||
if (decl.kind === SyntaxKind.ExportDeclaration) {
|
||||
searchForNamedImport(decl.exportClause);
|
||||
if (decl.exportClause && isNamedExports(decl.exportClause)) {
|
||||
searchForNamedImport(decl.exportClause);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -326,7 +328,7 @@ namespace ts.FindAllReferences {
|
||||
return !!forEachPossibleImportOrExportStatement(sourceFileLike, statement => {
|
||||
if (!isExportDeclaration(statement)) return;
|
||||
const { exportClause, moduleSpecifier } = statement;
|
||||
return !moduleSpecifier && exportClause &&
|
||||
return !moduleSpecifier && exportClause && isNamedExports(exportClause) &&
|
||||
exportClause.elements.some(element => checker.getExportSpecifierLocalTargetSymbol(element) === namespaceImportSymbol);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ namespace ts.OrganizeImports {
|
||||
}
|
||||
|
||||
const newExportSpecifiers: ExportSpecifier[] = [];
|
||||
newExportSpecifiers.push(...flatMap(namedExports, i => (i.exportClause!).elements));
|
||||
newExportSpecifiers.push(...flatMap(namedExports, i => i.exportClause && isNamedExports(i.exportClause) ? i.exportClause.elements : emptyArray));
|
||||
|
||||
const sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers);
|
||||
|
||||
@@ -317,7 +317,11 @@ namespace ts.OrganizeImports {
|
||||
exportDecl,
|
||||
exportDecl.decorators,
|
||||
exportDecl.modifiers,
|
||||
updateNamedExports(exportDecl.exportClause!, sortedExportSpecifiers),
|
||||
exportDecl.exportClause && (
|
||||
isNamedExports(exportDecl.exportClause) ?
|
||||
updateNamedExports(exportDecl.exportClause, sortedExportSpecifiers) :
|
||||
updateNamespaceExport(exportDecl.exportClause, exportDecl.exportClause.name)
|
||||
),
|
||||
exportDecl.moduleSpecifier));
|
||||
|
||||
return coalescedExports;
|
||||
|
||||
@@ -752,8 +752,14 @@ namespace ts {
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
// Handle named exports case e.g.:
|
||||
// export {a, b as B} from "mod";
|
||||
if ((<ExportDeclaration>node).exportClause) {
|
||||
forEach((<ExportDeclaration>node).exportClause!.elements, visit);
|
||||
const exportDeclaration = (<ExportDeclaration>node);
|
||||
if (exportDeclaration.exportClause) {
|
||||
if (isNamedExports(exportDeclaration.exportClause)) {
|
||||
forEach(exportDeclaration.exportClause.elements, visit);
|
||||
}
|
||||
else {
|
||||
visit(exportDeclaration.exportClause.name);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -373,6 +373,7 @@ namespace ts {
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
case SyntaxKind.NamespaceImport:
|
||||
case SyntaxKind.NamespaceExport:
|
||||
return ScriptElementKind.alias;
|
||||
case SyntaxKind.BinaryExpression:
|
||||
const kind = getAssignmentDeclarationKind(node as BinaryExpression);
|
||||
|
||||
Reference in New Issue
Block a user