-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: FormatterThe issue relates to the built-in formatterThe issue relates to the built-in formatterDomain: 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
Milestone
Description
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
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: FormatterThe issue relates to the built-in formatterThe issue relates to the built-in formatterDomain: 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