markAliasReferenced should include ExportValue as well (#51219)

This commit is contained in:
Ron Buckton
2022-10-19 13:24:01 -04:00
committed by GitHub
parent 5ef2634f3d
commit 2dff34e8c4
5 changed files with 90 additions and 2 deletions

View File

@@ -26035,13 +26035,13 @@ namespace ts {
function markAliasReferenced(symbol: Symbol, location: Node) {
if (isNonLocalAlias(symbol, /*excludes*/ SymbolFlags.Value) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol, SymbolFlags.Value)) {
const target = resolveAlias(symbol);
if (getAllSymbolFlags(target) & SymbolFlags.Value) {
if (getAllSymbolFlags(target) & (SymbolFlags.Value | SymbolFlags.ExportValue)) {
// An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled
// (because the const enum value will not be inlined), or if (2) the alias is an export
// of a const enum declaration that will be preserved.
if (compilerOptions.isolatedModules ||
shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(location) ||
!isConstEnumOrConstEnumOnlyModule(target)
!isConstEnumOrConstEnumOnlyModule(getExportSymbolOfValueSymbolIfExported(target))
) {
markAliasSymbolAsReferenced(symbol);
}