@@ -1551,7 +1551,7 @@ namespace ts {
15511551 const moduleExport = moduleExports.get(name);
15521552 if (moduleExport &&
15531553 moduleExport.flags === SymbolFlags.Alias &&
1554- getDeclarationOfKind(moduleExport, SyntaxKind.ExportSpecifier)) {
1554+ ( getDeclarationOfKind(moduleExport, SyntaxKind.ExportSpecifier) || getDeclarationOfKind(moduleExport, SyntaxKind.NamespaceExport) )) {
15551555 break;
15561556 }
15571557 }
@@ -2221,6 +2221,11 @@ namespace ts {
22212221 return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias, /*suppressUsageError*/ false);
22222222 }
22232223
2224+ function getTargetOfNamespaceExport(node: NamespaceExport, dontResolveAlias: boolean): Symbol | undefined {
2225+ const moduleSpecifier = node.parent.moduleSpecifier;
2226+ return moduleSpecifier && resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias, /*suppressUsageError*/ false);
2227+ }
2228+
22242229 // This function creates a synthetic symbol that combines the value side of one symbol with the
22252230 // type/namespace side of another symbol. Consider this example:
22262231 //
@@ -2386,6 +2391,8 @@ namespace ts {
23862391 return getTargetOfImportClause(<ImportClause>node, dontRecursivelyResolve);
23872392 case SyntaxKind.NamespaceImport:
23882393 return getTargetOfNamespaceImport(<NamespaceImport>node, dontRecursivelyResolve);
2394+ case SyntaxKind.NamespaceExport:
2395+ return getTargetOfNamespaceExport(<NamespaceExport>node, dontRecursivelyResolve);
23892396 case SyntaxKind.ImportSpecifier:
23902397 return getTargetOfImportSpecifier(<ImportSpecifier>node, dontRecursivelyResolve);
23912398 case SyntaxKind.ExportSpecifier:
@@ -5081,18 +5088,18 @@ namespace ts {
50815088
50825089 function mergeExportDeclarations(statements: Statement[]) {
50835090 // Pass 2: Combine all `export {}` declarations
5084- const exports = filter(statements, d => isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause) as ExportDeclaration[];
5091+ const exports = filter(statements, d => isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause && isNamedExports(d.exportClause) ) as ExportDeclaration[];
50855092 if (length(exports) > 1) {
50865093 const nonExports = filter(statements, d => !isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause);
50875094 statements = [...nonExports, createExportDeclaration(
50885095 /*decorators*/ undefined,
50895096 /*modifiers*/ undefined,
5090- createNamedExports(flatMap(exports, e => e.exportClause! .elements)),
5097+ createNamedExports(flatMap(exports, e => cast( e.exportClause, isNamedExports) .elements)),
50915098 /*moduleSpecifier*/ undefined
50925099 )];
50935100 }
50945101 // Pass 2b: Also combine all `export {} from "..."` declarations as needed
5095- const reexports = filter(statements, d => isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause) as ExportDeclaration[];
5102+ const reexports = filter(statements, d => isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause && isNamedExports(d.exportClause) ) as ExportDeclaration[];
50965103 if (length(reexports) > 1) {
50975104 const groups = group(reexports, decl => isStringLiteral(decl.moduleSpecifier!) ? ">" + decl.moduleSpecifier.text : ">");
50985105 if (groups.length !== reexports.length) {
@@ -5104,7 +5111,7 @@ namespace ts {
51045111 createExportDeclaration(
51055112 /*decorators*/ undefined,
51065113 /*modifiers*/ undefined,
5107- createNamedExports(flatMap(group, e => e.exportClause! .elements)),
5114+ createNamedExports(flatMap(group, e => cast( e.exportClause, isNamedExports) .elements)),
51085115 group[0].moduleSpecifier
51095116 )
51105117 ];
@@ -5118,8 +5125,8 @@ namespace ts {
51185125 function inlineExportModifiers(statements: Statement[]) {
51195126 // Pass 3: Move all `export {}`'s to `export` modifiers where possible
51205127 const exportDecl = find(statements, d => isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause) as ExportDeclaration | undefined;
5121- if (exportDecl) {
5122- const replacements = mapDefined(exportDecl.exportClause! .elements, e => {
5128+ if (exportDecl && exportDecl.exportClause && isNamedExports(exportDecl.exportClause) ) {
5129+ const replacements = mapDefined(exportDecl.exportClause.elements, e => {
51235130 if (!e.propertyName) {
51245131 // export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it
51255132 const associated = filter(statements, s => nodeHasName(s, e.name));
@@ -5137,7 +5144,7 @@ namespace ts {
51375144 else {
51385145 // some items filtered, others not - update the export declaration
51395146 // (mutating because why not, we're building a whole new tree here anyway)
5140- exportDecl.exportClause! .elements = createNodeArray(replacements);
5147+ exportDecl.exportClause.elements = createNodeArray(replacements);
51415148 }
51425149 }
51435150 return statements;
@@ -5653,6 +5660,14 @@ namespace ts {
56535660 createLiteral(getSpecifierForModuleSymbol(target, context))
56545661 ), ModifierFlags.None);
56555662 break;
5663+ case SyntaxKind.NamespaceExport:
5664+ addResult(createExportDeclaration(
5665+ /*decorators*/ undefined,
5666+ /*modifiers*/ undefined,
5667+ createNamespaceExport(createIdentifier(localName)),
5668+ createLiteral(getSpecifierForModuleSymbol(target, context))
5669+ ), ModifierFlags.None);
5670+ break;
56565671 case SyntaxKind.ImportSpecifier:
56575672 addResult(createImportDeclaration(
56585673 /*decorators*/ undefined,
@@ -32608,7 +32623,7 @@ namespace ts {
3260832623 return true;
3260932624 }
3261032625
32611- function checkAliasSymbol(node: ImportEqualsDeclaration | ImportClause | NamespaceImport | ImportSpecifier | ExportSpecifier) {
32626+ function checkAliasSymbol(node: ImportEqualsDeclaration | ImportClause | NamespaceImport | ImportSpecifier | ExportSpecifier | NamespaceExport ) {
3261232627 let symbol = getSymbolOfNode(node);
3261332628 const target = resolveAlias(symbol);
3261432629
@@ -32727,7 +32742,12 @@ namespace ts {
3272732742 if (node.exportClause) {
3272832743 // export { x, y }
3272932744 // export { x, y } from "foo"
32730- forEach(node.exportClause.elements, checkExportSpecifier);
32745+ if (isNamedExports(node.exportClause)) {
32746+ forEach(node.exportClause.elements, checkExportSpecifier);
32747+ }
32748+ else if(!isNamespaceExport(node.exportClause)) {
32749+ checkImportBinding(node.exportClause);
32750+ }
3273132751
3273232752 const inAmbientExternalModule = node.parent.kind === SyntaxKind.ModuleBlock && isAmbientModule(node.parent.parent);
3273332753 const inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === SyntaxKind.ModuleBlock &&
@@ -34157,7 +34177,10 @@ namespace ts {
3415734177 return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol);
3415834178 case SyntaxKind.ExportDeclaration:
3415934179 const exportClause = (<ExportDeclaration>node).exportClause;
34160- return !!exportClause && some(exportClause.elements, isValueAliasDeclaration);
34180+ return !!exportClause && (
34181+ isNamespaceExport(exportClause) ||
34182+ some(exportClause.elements, isValueAliasDeclaration)
34183+ );
3416134184 case SyntaxKind.ExportAssignment:
3416234185 return (<ExportAssignment>node).expression && (<ExportAssignment>node).expression.kind === SyntaxKind.Identifier ?
3416334186 isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) :
0 commit comments