mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-22 02:35:48 -05:00
extractMethod: Don't try to extract an ExpressionStatement consisting of a single token (#18450)
* extractMethod: Don't try to extract an ExpressionStatement consisting of a single token * Move to unit test
This commit is contained in:
@@ -410,6 +410,8 @@ function test(x: number) {
|
||||
"Statement or expression expected."
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extract-method-not-for-token-expression-statement", `[#|a|]`, ["Select more than a single token."]);
|
||||
|
||||
testExtractMethod("extractMethod1",
|
||||
`namespace A {
|
||||
let x = 1;
|
||||
|
||||
@@ -231,7 +231,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