Error on invalid uses of namespace export (#37715)

This commit is contained in:
Andrew Branch
2020-04-09 08:42:16 -08:00
committed by GitHub
parent 57f9076612
commit 24a17acf2c
10 changed files with 115 additions and 10 deletions

View File

@@ -34018,7 +34018,7 @@ namespace ts {
return false;
}
if (inAmbientExternalModule && isExternalModuleNameRelative(moduleName.text)) {
// we have already reported errors on top level imports\exports in external module augmentations in checkModuleDeclaration
// we have already reported errors on top level imports/exports in external module augmentations in checkModuleDeclaration
// no need to do this again.
if (!isTopLevelInExternalModuleAugmentation(node)) {
// TypeScript 1.0 spec (April 2013): 12.1.6
@@ -34154,16 +34154,10 @@ namespace ts {
checkGrammarExportDeclaration(node);
if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) {
if (node.exportClause) {
if (node.exportClause && !isNamespaceExport(node.exportClause)) {
// export { x, y }
// export { x, y } from "foo"
if (isNamedExports(node.exportClause)) {
forEach(node.exportClause.elements, checkExportSpecifier);
}
else if(!isNamespaceExport(node.exportClause)) {
checkImportBinding(node.exportClause);
}
forEach(node.exportClause.elements, checkExportSpecifier);
const inAmbientExternalModule = node.parent.kind === SyntaxKind.ModuleBlock && isAmbientModule(node.parent.parent);
const inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === SyntaxKind.ModuleBlock &&
!node.moduleSpecifier && node.flags & NodeFlags.Ambient;
@@ -34177,7 +34171,9 @@ namespace ts {
if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) {
error(node.moduleSpecifier, Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol));
}
else if (node.exportClause) {
checkAliasSymbol(node.exportClause);
}
if (moduleKind !== ModuleKind.System && moduleKind < ModuleKind.ES2015) {
checkExternalEmitHelpers(node, ExternalEmitHelpers.ExportStar);
}