Skip to content

Commit f00d3fc

Browse files
author
Andy
authored
Merge pull request #9897 from Microsoft/umd_export
Clarify code checking for UMD exports...
2 parents fe642f5 + 715d3f2 commit f00d3fc

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/compiler/checker.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18449,7 +18449,7 @@ namespace ts {
1844918449

1845018450
// When resolved as an expression identifier, if the given node references an exported entity, return the declaration
1845118451
// node of the exported entity's container. Otherwise, return undefined.
18452-
function getReferencedExportContainer(node: Identifier, prefixLocals?: boolean): SourceFile | ModuleDeclaration | EnumDeclaration {
18452+
function getReferencedExportContainer(node: Identifier, prefixLocals?: boolean): SourceFile | ModuleDeclaration | EnumDeclaration | undefined {
1845318453
node = getParseTreeNode(node, isIdentifier);
1845418454
if (node) {
1845518455
// When resolving the export container for the name of a module or enum
@@ -18471,10 +18471,11 @@ namespace ts {
1847118471
const parentSymbol = getParentOfSymbol(symbol);
1847218472
if (parentSymbol) {
1847318473
if (parentSymbol.flags & SymbolFlags.ValueModule && parentSymbol.valueDeclaration.kind === SyntaxKind.SourceFile) {
18474+
const symbolFile = <SourceFile>parentSymbol.valueDeclaration;
18475+
const referenceFile = getSourceFileOfNode(node);
1847418476
// If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined.
18475-
if (parentSymbol.valueDeclaration === getSourceFileOfNode(node)) {
18476-
return <SourceFile>parentSymbol.valueDeclaration;
18477-
}
18477+
const symbolIsUmdExport = symbolFile !== referenceFile;
18478+
return symbolIsUmdExport ? undefined : symbolFile;
1847818479
}
1847918480
for (let n = node.parent; n; n = n.parent) {
1848018481
if (isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol) {
@@ -18484,8 +18485,6 @@ namespace ts {
1848418485
}
1848518486
}
1848618487
}
18487-
18488-
return undefined;
1848918488
}
1849018489

1849118490
// When resolved as an expression identifier, if the given node references an import, return the declaration of

0 commit comments

Comments
 (0)