mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 01:49:57 -05:00
extractMethod: Don't try to extract an ExpressionStatement consisting of a single token (#18450) (#18473)
* extractMethod: Don't try to extract an ExpressionStatement consisting of a single token * Move to unit test
This commit is contained in:
@@ -378,6 +378,8 @@ namespace A {
|
||||
"Cannot extract range containing conditional return statement."
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extract-method-not-for-token-expression-statement", `[#|a|]`, ["Select more than a single token."]);
|
||||
|
||||
testExtractMethod("extractMethod1",
|
||||
`namespace A {
|
||||
let x = 1;
|
||||
|
||||
@@ -227,7 +227,7 @@ namespace ts.refactor.extractMethod {
|
||||
}
|
||||
|
||||
function checkRootNode(node: Node): Diagnostic[] | undefined {
|
||||
if (isToken(node)) {
|
||||
if (isToken(isExpressionStatement(node) ? node.expression : node)) {
|
||||
return [createDiagnosticForNode(node, Messages.InsufficientSelection)];
|
||||
}
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user