@@ -639,6 +639,7 @@ namespace ts {
639639 let propertyWithInvalidInitializer: Node;
640640 const errorLocation = location;
641641 let grandparent: Node;
642+ let isInExternalModule = false;
642643
643644 loop: while (location) {
644645 // Locals of a source file are not in scope (because they get merged into the global symbol table)
@@ -686,6 +687,7 @@ namespace ts {
686687 switch (location.kind) {
687688 case SyntaxKind.SourceFile:
688689 if (!isExternalOrCommonJsModule(<SourceFile>location)) break;
690+ isInExternalModule = true;
689691 case SyntaxKind.ModuleDeclaration:
690692 const moduleExports = getSymbolOfNode(location).exports;
691693 if (location.kind === SyntaxKind.SourceFile || isAmbientModule(location)) {
@@ -879,6 +881,14 @@ namespace ts {
879881 checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
880882 }
881883 }
884+
885+ // If we're in an external module, we can't reference symbols created from UMD export declarations
886+ if (result && isInExternalModule) {
887+ const decls = result.declarations;
888+ if (decls && decls.length === 1 && decls[0].kind === SyntaxKind.NamespaceExportDeclaration) {
889+ error(errorLocation, Diagnostics.Identifier_0_must_be_imported_from_a_module, name);
890+ }
891+ }
882892 }
883893 return result;
884894 }
@@ -1076,7 +1086,7 @@ namespace ts {
10761086 return getExternalModuleMember(<ImportDeclaration>node.parent.parent.parent, node);
10771087 }
10781088
1079- function getTargetOfGlobalModuleExportDeclaration(node: GlobalModuleExportDeclaration ): Symbol {
1089+ function getTargetOfGlobalModuleExportDeclaration(node: NamespaceExportDeclaration ): Symbol {
10801090 return resolveExternalModuleSymbol(node.parent.symbol);
10811091 }
10821092
@@ -1104,8 +1114,8 @@ namespace ts {
11041114 return getTargetOfExportSpecifier(<ExportSpecifier>node);
11051115 case SyntaxKind.ExportAssignment:
11061116 return getTargetOfExportAssignment(<ExportAssignment>node);
1107- case SyntaxKind.GlobalModuleExportDeclaration :
1108- return getTargetOfGlobalModuleExportDeclaration(<GlobalModuleExportDeclaration >node);
1117+ case SyntaxKind.NamespaceExportDeclaration :
1118+ return getTargetOfGlobalModuleExportDeclaration(<NamespaceExportDeclaration >node);
11091119 }
11101120 }
11111121
@@ -6374,7 +6384,7 @@ namespace ts {
63746384 if (kind === SignatureKind.Construct && sourceSignatures.length && targetSignatures.length) {
63756385 if (isAbstractConstructorType(source) && !isAbstractConstructorType(target)) {
63766386 // An abstract constructor type is not assignable to a non-abstract constructor type
6377- // as it would otherwise be possible to new an abstract class. Note that the assignability
6387+ // as it would otherwise be possible to new an abstract class. Note that the assignability
63786388 // check we perform for an extends clause excludes construct signatures from the target,
63796389 // so this check never proceeds.
63806390 if (reportErrors) {
@@ -12878,7 +12888,7 @@ namespace ts {
1287812888 if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(
1287912889 <BindingPattern>name,
1288012890 predicateVariableNode,
12881- predicateVariableName)) {
12891+ predicateVariableName)) {
1288212892 return true;
1288312893 }
1288412894 }
@@ -17497,7 +17507,7 @@ namespace ts {
1749717507 if (file.moduleAugmentations.length) {
1749817508 (augmentations || (augmentations = [])).push(file.moduleAugmentations);
1749917509 }
17500- if (file.wasReferenced && file. symbol && file.symbol.globalExports) {
17510+ if (file.symbol && file.symbol.globalExports) {
1750117511 mergeSymbolTable(globals, file.symbol.globalExports);
1750217512 }
1750317513 });
0 commit comments