mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 11:24:29 -05:00
Fix const enum comments (#47990)
* chore: add test case * fix: const enum comment * fix: replace all unsafe pattern * chore: run regex only if element access
This commit is contained in:
@@ -3355,6 +3355,10 @@ namespace ts {
|
||||
return substituteConstantValue(node);
|
||||
}
|
||||
|
||||
function safeMultiLineComment(value: string): string {
|
||||
return value.replace(/\*\//g, "*_/");
|
||||
}
|
||||
|
||||
function substituteConstantValue(node: PropertyAccessExpression | ElementAccessExpression): LeftHandSideExpression {
|
||||
const constantValue = tryGetConstEnumValue(node);
|
||||
if (constantValue !== undefined) {
|
||||
@@ -3366,7 +3370,7 @@ namespace ts {
|
||||
const originalNode = getOriginalNode(node, isAccessExpression);
|
||||
const propertyName = isPropertyAccessExpression(originalNode)
|
||||
? declarationNameToString(originalNode.name)
|
||||
: getTextOfNode(originalNode.argumentExpression);
|
||||
: safeMultiLineComment(getTextOfNode(originalNode.argumentExpression));
|
||||
|
||||
addSyntheticTrailingComment(substitute, SyntaxKind.MultiLineCommentTrivia, ` ${propertyName} `);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user