Disallow object prototype property access on const enums (#55424)

This commit is contained in:
Mateusz Burzyński
2023-08-28 19:29:52 -07:00
committed by GitHub
parent 418494e4c4
commit 9f9a72a2eb
5 changed files with 172 additions and 1 deletions
+1 -1
View File
@@ -32123,7 +32123,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}
return isErrorType(apparentType) ? errorType : apparentType;
}
prop = getPropertyOfType(apparentType, right.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ node.kind === SyntaxKind.QualifiedName);
prop = getPropertyOfType(apparentType, right.escapedText, /*skipObjectFunctionPropertyAugment*/ isConstEnumObjectType(apparentType), /*includeTypeOnlyMembers*/ node.kind === SyntaxKind.QualifiedName);
}
// 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