mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 01:04:49 -05:00
Fixes indentation of object literals with computed properties
This commit is contained in:
@@ -964,9 +964,18 @@ const _super = (function (geti, seti) {
|
||||
write("{}");
|
||||
}
|
||||
else {
|
||||
const indentedFlag = getNodeEmitFlags(node) & NodeEmitFlags.Indented;
|
||||
if (indentedFlag) {
|
||||
increaseIndent();
|
||||
}
|
||||
|
||||
const preferNewLine = node.multiLine ? ListFormat.PreferNewLine : ListFormat.None;
|
||||
const allowTrailingComma = languageVersion >= ScriptTarget.ES5 ? ListFormat.AllowTrailingComma : ListFormat.None;
|
||||
emitList(node, properties, ListFormat.ObjectLiteralExpressionProperties | allowTrailingComma | preferNewLine);
|
||||
|
||||
if (indentedFlag) {
|
||||
decreaseIndent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1688,10 +1688,13 @@ namespace ts {
|
||||
addNode(expressions,
|
||||
createAssignment(
|
||||
temp,
|
||||
createObjectLiteral(
|
||||
visitNodes(properties, visitor, isObjectLiteralElement, 0, numInitialNonComputedProperties),
|
||||
/*location*/ undefined,
|
||||
node.multiLine
|
||||
setNodeEmitFlags(
|
||||
createObjectLiteral(
|
||||
visitNodes(properties, visitor, isObjectLiteralElement, 0, numInitialNonComputedProperties),
|
||||
/*location*/ undefined,
|
||||
node.multiLine
|
||||
),
|
||||
NodeEmitFlags.Indented
|
||||
)
|
||||
),
|
||||
node.multiLine
|
||||
|
||||
@@ -1637,6 +1637,9 @@ namespace ts {
|
||||
const rightHandSideName = (<PropertyAccessExpression>nameExpression).name.text;
|
||||
return getPropertyNameForKnownSymbolName(rightHandSideName);
|
||||
}
|
||||
if (isStringOrNumericLiteral(nameExpression.kind)) {
|
||||
return (<LiteralExpression>nameExpression).text;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user