mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-29 16:29:19 -05:00
Ensure enum aliases referenced in other enum members do not get marked as referenced (#48770)
* Add test * Ensure enum aliases referenced in other enum members do not get marked as referenced
This commit is contained in:
@@ -28946,10 +28946,17 @@ namespace ts {
|
||||
prop = getPropertyOfType(apparentType, right.escapedText);
|
||||
}
|
||||
// In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums.
|
||||
// `Foo` is also not referenced in `enum FooCopy { Bar = Foo.Bar }`, because the enum member value gets inlined
|
||||
// here even if `Foo` is not a const enum.
|
||||
//
|
||||
// The exceptions are:
|
||||
// 1. if 'isolatedModules' is enabled, because the const enum value will not be inlined, and
|
||||
// 2. if 'preserveConstEnums' is enabled and the expression is itself an export, e.g. `export = Foo.Bar.Baz`.
|
||||
if (isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || !(prop && isConstEnumOrConstEnumOnlyModule(prop)) || shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) {
|
||||
if (isIdentifier(left) && parentSymbol && (
|
||||
compilerOptions.isolatedModules ||
|
||||
!(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & SymbolFlags.EnumMember && node.parent.kind === SyntaxKind.EnumMember)) ||
|
||||
shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node)
|
||||
)) {
|
||||
markAliasReferenced(parentSymbol, node);
|
||||
}
|
||||
|
||||
@@ -40224,7 +40231,7 @@ namespace ts {
|
||||
|
||||
function isConstantMemberAccess(node: Expression): node is AccessExpression {
|
||||
const type = getTypeOfExpression(node);
|
||||
if(type === errorType) {
|
||||
if (type === errorType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user