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:
Andy
2017-09-14 11:16:21 -07:00
committed by GitHub
parent 76eab54ab7
commit 6e512a495f
2 changed files with 3 additions and 1 deletions

View File

@@ -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;

View File

@@ -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;