diff --git a/src/services/codefixes/fixJSDocTypes.ts b/src/services/codefixes/fixJSDocTypes.ts
index 4f89a17132..2ca8702047 100644
--- a/src/services/codefixes/fixJSDocTypes.ts
+++ b/src/services/codefixes/fixJSDocTypes.ts
@@ -7,13 +7,14 @@ namespace ts.codefix {
function getActionsForJSDocTypes(context: CodeFixContext): CodeAction[] | undefined {
const sourceFile = context.sourceFile;
-
const node = getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false);
- if (node.kind !== SyntaxKind.VariableDeclaration) return;
+ const decl = ts.findAncestor(node, n => n.kind === SyntaxKind.VariableDeclaration);
+ if (!decl) return;
+ const jsdocType = (decl as VariableDeclaration).type;
+
+ // TODO: Only if get(jsdoctype) !== jsdoctype
const trk = textChanges.ChangeTracker.fromCodeFixContext(context);
- const jsdocType = (node as VariableDeclaration).type;
- // TODO: Only if get(jsdoctype) !== jsdoctype
trk.replaceNode(sourceFile, jsdocType, getTypeFromJSDocType(jsdocType));
return [{
// TODO: This seems like the LEAST SAFE way to get the new text
diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax3.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax3.ts
index d64ed7f1b0..f3b02cb84f 100644
--- a/tests/cases/fourslash/codeFixChangeJSDocSyntax3.ts
+++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax3.ts
@@ -1,4 +1,4 @@
///
-//// var x: [|...number|] = 12;
+//// var x: [|......number[][]|] = 12;
-verify.rangeAfterCodeFix("number[]");
+verify.rangeAfterCodeFix("number[][][][]");
diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax4.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax4.ts
new file mode 100644
index 0000000000..8eb06c102d
--- /dev/null
+++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax4.ts
@@ -0,0 +1,4 @@
+///
+//// var x: [|Array.|] = 12;
+
+verify.rangeAfterCodeFix("Array");