Skip to content

Commit a5bef21

Browse files
author
Arthur Ozga
committed
Use symbolToName instead of copying
1 parent d2bda47 commit a5bef21

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,7 +2287,7 @@ namespace ts {
22872287
interface NodeBuilderContext {
22882288
readonly enclosingDeclaration: Node | undefined;
22892289
readonly flags: NodeBuilderFlags | undefined;
2290-
2290+
22912291
// State
22922292
encounteredError: boolean;
22932293
inObjectTypeLiteral: boolean;
@@ -2564,7 +2564,6 @@ namespace ts {
25642564
return createTypeLiteralNode(members);
25652565
}
25662566

2567-
25682567
function shouldAddParenthesisAroundFunctionType(callSignature: Signature, context: NodeBuilderContext) {
25692568
if (InElementType) {
25702569
return true;
@@ -2670,13 +2669,10 @@ namespace ts {
26702669
return typeElements;
26712670
}
26722671

2672+
// TODO: make logic mirror that of writeObjectLiteralType
26732673
for (const propertySymbol of properties) {
26742674
const propertyType = getTypeOfSymbol(propertySymbol);
2675-
const oldDeclaration = propertySymbol.declarations && propertySymbol.declarations[0] as TypeElement;
2676-
if (!oldDeclaration) {
2677-
return;
2678-
}
2679-
const propertyName = getDeepSynthesizedClone(oldDeclaration.name);
2675+
const propertyName = symbolToName(propertySymbol, /*expectsIdentifier*/ true, context);
26802676
const optionalToken = propertySymbol.flags & SymbolFlags.Optional ? createToken(SyntaxKind.QuestionToken) : undefined;
26812677
if (propertySymbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(propertyType).length) {
26822678
const signatures = getSignaturesOfType(propertyType, SignatureKind.Call);
@@ -2697,7 +2693,7 @@ namespace ts {
26972693
propertyName,
26982694
optionalToken,
26992695
propertyTypeNode,
2700-
/*initializer*/undefined);
2696+
/*initializer*/ undefined);
27012697
typeElements.push(propertySignature);
27022698
}
27032699
}
@@ -2744,8 +2740,8 @@ namespace ts {
27442740
const returnType = getReturnTypeOfSignature(signature);
27452741
returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context);
27462742
}
2747-
if(context.flags & NodeBuilderFlags.SuppressAnyReturnType) {
2748-
if(returnTypeNode && returnTypeNode.kind === SyntaxKind.AnyKeyword) {
2743+
if (context.flags & NodeBuilderFlags.SuppressAnyReturnType) {
2744+
if (returnTypeNode && returnTypeNode.kind === SyntaxKind.AnyKeyword) {
27492745
returnTypeNode = undefined;
27502746
}
27512747
}

0 commit comments

Comments
 (0)