Repository: microsoft/TypeScript
File: src/compiler/transformers/declarations.ts (TypeScript)

Code before:
                        heritageClauses,
                        members
                    ))!]; // TODO: GH#18217
                }
                else {
                    const heritageClauses = transformHeritageClauses(input.heritageClauses);
                    return cleanup(factory.updateClassDeclaration(
                        input,
                        modifiers,
                        input.name,
                        typeParameters,
                        heritageClauses,
                        members
                    ));
                }
            }
            case SyntaxKind.VariableStatement: {
                return cleanup(transformVariableStatement(input));
            }
            case SyntaxKind.EnumDeclaration: {
                return cleanup(factory.updateEnumDeclaration(input, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(mapDefined(input.members, m => {
                    if (shouldStripInternal(m)) return;
                    // Rewrite enum values to their constants, if available
                    const constValue = resolver.getConstantValue(m);
                    const newInitializer = typeof constValue === "undefined"
                        ? undefined
                        : typeof constValue === "string"
                        ? factory.createStringLiteral(constValue)
                        : constValue < 0
                        ? factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(constValue)))
                        : factory.createNumericLiteral(constValue);
                    return preserveJsDoc(factory.updateEnumMember(m, m.name, newInitializer), m);
                }))));
            }
        }
        // Anything left unhandled is an error, so this should be unreachable
        return Debug.assertNever(input, `Unhandled top-level node in declaration emit: ${Debug.formatSyntaxKind((input as Node).kind)}`);

        function cleanup<T extends Node>(node: T | undefined): T | undefined {
            if (isEnclosingDeclaration(input)) {
                enclosingDeclaration = previousEnclosingDeclaration;
            }
            if (canProdiceDiagnostic) {
                getSymbolAccessibilityDiagnostic = oldDiag;
            }
            if (input.kind === SyntaxKind.ModuleDeclaration) {
                needsDeclare = previousNeedsDeclare;
            }
            if (node as Node === input) {
                return node;
            }

Review comment (suggestion):
```suggestion
                    const newInitializer = constValue === undefined
                        ? undefined

```

Code after:
                        heritageClauses,
                        members
                    ))!]; // TODO: GH#18217
                }
                else {
                    const heritageClauses = transformHeritageClauses(input.heritageClauses);
                    return cleanup(factory.updateClassDeclaration(
                        input,
                        modifiers,
                        input.name,
                        typeParameters,
                        heritageClauses,
                        members
                    ));
                }
            }
            case SyntaxKind.VariableStatement: {
                return cleanup(transformVariableStatement(input));
            }
            case SyntaxKind.EnumDeclaration: {
                return cleanup(factory.updateEnumDeclaration(input, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(mapDefined(input.members, m => {
                    if (shouldStripInternal(m)) return;
                    // Rewrite enum values to their constants, if available
                    const constValue = resolver.getConstantValue(m);
                    const newInitializer = constValue === undefined
                        ? undefined
                        : typeof constValue === "string"
                        ? factory.createStringLiteral(constValue)
                        : constValue < 0
                        ? factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(constValue)))
                        : factory.createNumericLiteral(constValue);
                    return preserveJsDoc(factory.updateEnumMember(m, m.name, newInitializer), m);
                }))));
            }
        }
        // Anything left unhandled is an error, so this should be unreachable
        return Debug.assertNever(input, `Unhandled top-level node in declaration emit: ${Debug.formatSyntaxKind((input as Node).kind)}`);

        function cleanup<T extends Node>(node: T | undefined): T | undefined {
            if (isEnclosingDeclaration(input)) {
                enclosingDeclaration = previousEnclosingDeclaration;
            }
            if (canProdiceDiagnostic) {
                getSymbolAccessibilityDiagnostic = oldDiag;
            }
            if (input.kind === SyntaxKind.ModuleDeclaration) {
                needsDeclare = previousNeedsDeclare;
            }
            if (node as Node === input) {
                return node;
            }