@@ -8127,8 +8127,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
81278127
81288128 function typeParameterToDeclaration(type: TypeParameter, context: NodeBuilderContext, constraint = getConstraintOfTypeParameter(type)): TypeParameterDeclaration {
81298129 const constraintNode = constraint && typeToTypeNodeHelperWithPossibleReusableTypeNode(constraint, getConstraintDeclaration(type), context);
8130- const typeParam = typeParameterToDeclarationWithConstraint(type, context, constraintNode);
8131- return typeParam;
8130+ return typeParameterToDeclarationWithConstraint(type, context, constraintNode);
81328131 }
81338132
81348133 function typePredicateToTypePredicateNodeHelper(typePredicate: TypePredicate, context: NodeBuilderContext): TypePredicateNode {
@@ -9878,12 +9877,24 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
98789877 // I hate that to get the initialized value we need to walk back to the declarations here; but there's no
98799878 // other way to get the possible const value of an enum member that I'm aware of, as the value is cached
98809879 // _on the declaration_, not on the declaration's symbol...
9881- const initializedValue = p.declarations && p.declarations[0] && isEnumMember(p.declarations[0]) ? getConstantValue(p.declarations[0]) : undefined;
9882- const initializer = initializedValue === undefined ? undefined :
9883- typeof initializedValue === "string" ? factory.createStringLiteral(initializedValue) :
9884- factory.createNumericLiteral(initializedValue);
9880+ const memberDecl = p.declarations && p.declarations[0] && isEnumMember(p.declarations[0]) ?
9881+ p.declarations[0] :
9882+ undefined;
9883+ let initializer: Expression | undefined;
9884+ let initializerLength: number;
9885+ if (isUnfolding(context) && memberDecl && memberDecl.initializer) {
9886+ initializer = visitNode(memberDecl.initializer, factory.cloneNode, isExpression);
9887+ initializerLength = memberDecl.initializer.end - memberDecl.initializer.pos;
9888+ }
9889+ else {
9890+ const initializedValue = memberDecl && getConstantValue(memberDecl);
9891+ initializer = initializedValue === undefined ? undefined :
9892+ typeof initializedValue === "string" ? factory.createStringLiteral(initializedValue) :
9893+ factory.createNumericLiteral(initializedValue);
9894+ initializerLength = (initializer as StringLiteral | NumericLiteral | undefined)?.text.length ?? 0
9895+ }
98859896 const memberName = unescapeLeadingUnderscores(p.escapedName);
9886- context.approximateLength += 4 + memberName.length + (initializer?.text.length ?? 0) ; // `member = initializer,`
9897+ context.approximateLength += 4 + memberName.length + initializerLength ; // `member = initializer,`
98879898 const member = factory.createEnumMember(
98889899 memberName,
98899900 initializer,
0 commit comments