@@ -1551,7 +1551,7 @@ namespace ts {
1551
1551
const moduleExport = moduleExports.get(name);
1552
1552
if (moduleExport &&
1553
1553
moduleExport.flags === SymbolFlags.Alias &&
1554
- getDeclarationOfKind(moduleExport, SyntaxKind.ExportSpecifier)) {
1554
+ ( getDeclarationOfKind(moduleExport, SyntaxKind.ExportSpecifier) || getDeclarationOfKind(moduleExport, SyntaxKind.NamespaceExport) )) {
1555
1555
break;
1556
1556
}
1557
1557
}
@@ -2221,6 +2221,11 @@ namespace ts {
2221
2221
return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias, /*suppressUsageError*/ false);
2222
2222
}
2223
2223
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
+
2224
2229
// This function creates a synthetic symbol that combines the value side of one symbol with the
2225
2230
// type/namespace side of another symbol. Consider this example:
2226
2231
//
@@ -2386,6 +2391,8 @@ namespace ts {
2386
2391
return getTargetOfImportClause(<ImportClause>node, dontRecursivelyResolve);
2387
2392
case SyntaxKind.NamespaceImport:
2388
2393
return getTargetOfNamespaceImport(<NamespaceImport>node, dontRecursivelyResolve);
2394
+ case SyntaxKind.NamespaceExport:
2395
+ return getTargetOfNamespaceExport(<NamespaceExport>node, dontRecursivelyResolve);
2389
2396
case SyntaxKind.ImportSpecifier:
2390
2397
return getTargetOfImportSpecifier(<ImportSpecifier>node, dontRecursivelyResolve);
2391
2398
case SyntaxKind.ExportSpecifier:
@@ -5081,18 +5088,18 @@ namespace ts {
5081
5088
5082
5089
function mergeExportDeclarations(statements: Statement[]) {
5083
5090
// 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[];
5085
5092
if (length(exports) > 1) {
5086
5093
const nonExports = filter(statements, d => !isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause);
5087
5094
statements = [...nonExports, createExportDeclaration(
5088
5095
/*decorators*/ undefined,
5089
5096
/*modifiers*/ undefined,
5090
- createNamedExports(flatMap(exports, e => e.exportClause! .elements)),
5097
+ createNamedExports(flatMap(exports, e => cast( e.exportClause, isNamedExports) .elements)),
5091
5098
/*moduleSpecifier*/ undefined
5092
5099
)];
5093
5100
}
5094
5101
// 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[];
5096
5103
if (length(reexports) > 1) {
5097
5104
const groups = group(reexports, decl => isStringLiteral(decl.moduleSpecifier!) ? ">" + decl.moduleSpecifier.text : ">");
5098
5105
if (groups.length !== reexports.length) {
@@ -5104,7 +5111,7 @@ namespace ts {
5104
5111
createExportDeclaration(
5105
5112
/*decorators*/ undefined,
5106
5113
/*modifiers*/ undefined,
5107
- createNamedExports(flatMap(group, e => e.exportClause! .elements)),
5114
+ createNamedExports(flatMap(group, e => cast( e.exportClause, isNamedExports) .elements)),
5108
5115
group[0].moduleSpecifier
5109
5116
)
5110
5117
];
@@ -5118,8 +5125,8 @@ namespace ts {
5118
5125
function inlineExportModifiers(statements: Statement[]) {
5119
5126
// Pass 3: Move all `export {}`'s to `export` modifiers where possible
5120
5127
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 => {
5123
5130
if (!e.propertyName) {
5124
5131
// export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it
5125
5132
const associated = filter(statements, s => nodeHasName(s, e.name));
@@ -5137,7 +5144,7 @@ namespace ts {
5137
5144
else {
5138
5145
// some items filtered, others not - update the export declaration
5139
5146
// (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);
5141
5148
}
5142
5149
}
5143
5150
return statements;
@@ -5653,6 +5660,14 @@ namespace ts {
5653
5660
createLiteral(getSpecifierForModuleSymbol(target, context))
5654
5661
), ModifierFlags.None);
5655
5662
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;
5656
5671
case SyntaxKind.ImportSpecifier:
5657
5672
addResult(createImportDeclaration(
5658
5673
/*decorators*/ undefined,
@@ -32608,7 +32623,7 @@ namespace ts {
32608
32623
return true;
32609
32624
}
32610
32625
32611
- function checkAliasSymbol(node: ImportEqualsDeclaration | ImportClause | NamespaceImport | ImportSpecifier | ExportSpecifier) {
32626
+ function checkAliasSymbol(node: ImportEqualsDeclaration | ImportClause | NamespaceImport | ImportSpecifier | ExportSpecifier | NamespaceExport ) {
32612
32627
let symbol = getSymbolOfNode(node);
32613
32628
const target = resolveAlias(symbol);
32614
32629
@@ -32727,7 +32742,12 @@ namespace ts {
32727
32742
if (node.exportClause) {
32728
32743
// export { x, y }
32729
32744
// 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
+ }
32731
32751
32732
32752
const inAmbientExternalModule = node.parent.kind === SyntaxKind.ModuleBlock && isAmbientModule(node.parent.parent);
32733
32753
const inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === SyntaxKind.ModuleBlock &&
@@ -34157,7 +34177,10 @@ namespace ts {
34157
34177
return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol);
34158
34178
case SyntaxKind.ExportDeclaration:
34159
34179
const exportClause = (<ExportDeclaration>node).exportClause;
34160
- return !!exportClause && some(exportClause.elements, isValueAliasDeclaration);
34180
+ return !!exportClause && (
34181
+ isNamespaceExport(exportClause) ||
34182
+ some(exportClause.elements, isValueAliasDeclaration)
34183
+ );
34161
34184
case SyntaxKind.ExportAssignment:
34162
34185
return (<ExportAssignment>node).expression && (<ExportAssignment>node).expression.kind === SyntaxKind.Identifier ?
34163
34186
isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) :
0 commit comments