Codefix for Array.<number> -> Array<number>
This commit is contained in:
parent
dba552d071
commit
3776b0b58b
|
@ -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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/// <reference path='fourslash.ts' />
|
||||
//// var x: [|...number|] = 12;
|
||||
//// var x: [|......number[][]|] = 12;
|
||||
|
||||
verify.rangeAfterCodeFix("number[]");
|
||||
verify.rangeAfterCodeFix("number[][][][]");
|
||||
|
|
4
tests/cases/fourslash/codeFixChangeJSDocSyntax4.ts
Normal file
4
tests/cases/fourslash/codeFixChangeJSDocSyntax4.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
/// <reference path='fourslash.ts' />
|
||||
//// var x: [|Array.<number>|] = 12;
|
||||
|
||||
verify.rangeAfterCodeFix("Array<number>");
|
Loading…
Reference in a new issue