@@ -6,13 +6,13 @@ export default {
6
6
kind : 'quickfix' ,
7
7
title : 'Declare missing property' ,
8
8
tryToApply ( { sourceFile, node } ) {
9
- const param = matchParents ( node , [ 'Identifier' , 'ObjectBindingPattern' , 'Parameter' ] )
9
+ const param = matchParents ( node , [ 'Identifier' , 'BindingElement' , ' ObjectBindingPattern', 'Parameter' ] )
10
10
if ( param ) {
11
11
// special react pattern
12
12
if ( ts . isArrowFunction ( param . parent ) && ts . isVariableDeclaration ( param . parent . parent ) ) {
13
13
const variableDecl = param . parent . parent
14
14
if ( variableDecl . type ?. getText ( ) . match ( / ( R e a c t \. ) ? F C / ) ) {
15
- // handle interface
15
+ // todo handle interface
16
16
}
17
17
}
18
18
// general patterns
@@ -24,21 +24,12 @@ export default {
24
24
if ( insertComma ) insertText = `, ${ insertText } `
25
25
// alternatively only one snippetEdit could be used with tsFull.escapeSnippetText(insertText) + $0
26
26
return {
27
- edits : [
28
- {
29
- newText : insertText ,
30
- span : {
31
- length : 0 ,
32
- start : insertPos ,
33
- } ,
34
- } ,
35
- ] ,
36
27
snippetEdits : [
37
28
{
38
- newText : '$0' ,
29
+ newText : ` ${ tsFull . escapeSnippetText ( insertText ) } $0` ,
39
30
span : {
40
31
length : 0 ,
41
- start : insertPos + insertText . length - 1 ,
32
+ start : insertPos ,
42
33
} ,
43
34
} ,
44
35
] ,
@@ -48,3 +39,16 @@ export default {
48
39
return
49
40
} ,
50
41
} as ExtendedCodeAction
42
+
43
+ const testCode = ( ) => {
44
+ const tester = ( code : string ) => {
45
+ // ^ - problem location in which quickfix needs to be tested (applied)
46
+ // | - cursor position after quickfix is applied
47
+ // [[...]] - applied part of the code
48
+ /* TODO */
49
+ }
50
+
51
+ tester ( /* ts */ `
52
+ const b = ({ b, ^a }: { b[[, a/*|*/]] }) => {}
53
+ ` )
54
+ }
0 commit comments