Skip to content

Commit 92dc69d

Browse files
committed
Fix bug at bind site rather than in declare func
1 parent f9b7d6e commit 92dc69d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/compiler/binder.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ namespace ts {
564564
// and this case is specially handled. Module augmentations should only be merged with original module definition
565565
// and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed.
566566
if (isJSDocTypeAlias(node)) Debug.assert(isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file.
567-
if ((!isAmbientModule(node) && (hasExportModifier || container.flags & NodeFlags.ExportContext)) || (isJSDocTypeAlias(node) && container.symbol)) {
567+
if ((!isAmbientModule(node) && (hasExportModifier || container.flags & NodeFlags.ExportContext)) || isJSDocTypeAlias(node)) {
568568
if (!container.locals || (hasModifier(node, ModifierFlags.Default) && !getDeclarationName(node))) {
569569
return declareSymbol(container.symbol.exports!, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default!
570570
}
@@ -2003,7 +2003,12 @@ namespace ts {
20032003
switch (getAssignmentDeclarationPropertyAccessKind(declName.parent)) {
20042004
case AssignmentDeclarationKind.ExportsProperty:
20052005
case AssignmentDeclarationKind.ModuleExports:
2006-
container = file;
2006+
if (!isExternalOrCommonJsModule(file)) {
2007+
container = undefined!;
2008+
}
2009+
else {
2010+
container = file;
2011+
}
20072012
break;
20082013
case AssignmentDeclarationKind.ThisProperty:
20092014
container = declName.parent.expression;
@@ -2017,7 +2022,9 @@ namespace ts {
20172022
case AssignmentDeclarationKind.None:
20182023
return Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration");
20192024
}
2020-
declareModuleMember(typeAlias, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes);
2025+
if (container) {
2026+
declareModuleMember(typeAlias, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes);
2027+
}
20212028
container = oldContainer;
20222029
}
20232030
}

0 commit comments

Comments
 (0)