Skip to content

Indentation is busted for extract function #18091

Closed
@DanielRosenwasser

Description

@DanielRosenwasser
export function interpret(expr: ast.Expression): number {
    switch (expr.kind) {
        case "BinaryExpression":
            const { left, right } = expr;
            return interpret(left) + interpret(right);
    }
}

Extract the entire function body out into its own function.

Expected:

export function interpret(expr): number {
    return newFunction(expr);
}

function newFunction(expr: any) {
    switch (expr.kind) {
        case "BinaryExpression":
            const { left, right } = expr;
            return interpret(left) + interpret(right);
    }
}

Actual:

export function interpret(expr): number {
    return newFunction();

    function newFunction() {
        switch(expr.kind) {
        case "BinaryExpression":
        const { left, right } = expr;
        return interpret(left) + interpret(right);
    }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: FormatterThe issue relates to the built-in formatterDomain: Refactoringse.g. extract to constant or function, rename symbolFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions