mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
Handle the combination of a write and a void return
When the return type is void, there's no `returnValueProperty`, but that doesn't mean we don't need a `return` at the call site. Fixes #18140.
This commit is contained in:
@@ -613,6 +613,13 @@ namespace A {
|
||||
[#|let a1 = { x: 1 };
|
||||
return a1.x + 10;|]
|
||||
}
|
||||
}`);
|
||||
// Write + void return
|
||||
testExtractMethod("extractMethod21",
|
||||
`function foo() {
|
||||
let x = 10;
|
||||
[#|x++;
|
||||
return;|]
|
||||
}`);
|
||||
});
|
||||
|
||||
|
||||
@@ -748,6 +748,10 @@ namespace ts.refactor.extractMethod {
|
||||
}
|
||||
else {
|
||||
newNodes.push(createStatement(createBinary(assignments[0].name, SyntaxKind.EqualsToken, call)));
|
||||
|
||||
if (range.facts & RangeFacts.HasReturn) {
|
||||
newNodes.push(createReturn());
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user