Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Indentation is busted for extract function #18091

Copy link
Copy link
@DanielRosenwasser

Description

@DanielRosenwasser
Issue body actions
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);
    }
    }
}
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.