mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-13 22:00:59 -05:00
Lock down computed names in object literals and classes under --isolatedDeclarations (#58596)
This commit is contained in:
@@ -26,7 +26,6 @@ import {
|
||||
isBlock,
|
||||
isConstTypeReference,
|
||||
isDeclarationReadonly,
|
||||
isEntityNameExpression,
|
||||
isGetAccessor,
|
||||
isIdentifier,
|
||||
isJSDocTypeAssertion,
|
||||
@@ -55,7 +54,6 @@ import {
|
||||
PropertySignature,
|
||||
SetAccessorDeclaration,
|
||||
SignatureDeclaration,
|
||||
SymbolAccessibility,
|
||||
SyntacticTypeNodeBuilderContext,
|
||||
SyntacticTypeNodeBuilderResolver,
|
||||
SyntaxKind,
|
||||
@@ -351,7 +349,7 @@ export function createSyntacticTypeNodeBuilder(options: CompilerOptions, resolve
|
||||
}
|
||||
else if (prop.name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
const expression = prop.name.expression;
|
||||
if (!isPrimitiveLiteralValue(expression, /*includeBigInt*/ false) && !isEntityNameExpression(expression)) {
|
||||
if (!isPrimitiveLiteralValue(expression, /*includeBigInt*/ false)) {
|
||||
context.tracker.reportInferenceFallback(prop.name);
|
||||
result = false;
|
||||
}
|
||||
@@ -367,17 +365,6 @@ export function createSyntacticTypeNodeBuilder(options: CompilerOptions, resolve
|
||||
Debug.assert(!isShorthandPropertyAssignment(prop) && !isSpreadAssignment(prop));
|
||||
|
||||
const name = prop.name;
|
||||
if (prop.name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
if (!resolver.isNonNarrowedBindableName(prop.name)) {
|
||||
context.tracker.reportInferenceFallback(prop.name);
|
||||
}
|
||||
else if (isEntityNameExpression(prop.name.expression)) {
|
||||
const visibilityResult = resolver.isEntityNameVisible(prop.name.expression, context.enclosingDeclaration!, /*shouldComputeAliasToMakeVisible*/ false);
|
||||
if (visibilityResult.accessibility !== SymbolAccessibility.Accessible) {
|
||||
context.tracker.reportInferenceFallback(prop.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (prop.kind) {
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
canInferObjectLiteral = !!typeFromObjectLiteralMethod(prop, name, context) && canInferObjectLiteral;
|
||||
|
||||
Reference in New Issue
Block a user