@@ -6,13 +6,13 @@ export default {
66 kind : 'quickfix' ,
77 title : 'Declare missing property' ,
88 tryToApply ( { sourceFile, node } ) {
9- const param = matchParents ( node , [ 'Identifier' , 'ObjectBindingPattern' , 'Parameter' ] )
9+ const param = matchParents ( node , [ 'Identifier' , 'BindingElement' , ' ObjectBindingPattern', 'Parameter' ] )
1010 if ( param ) {
1111 // special react pattern
1212 if ( ts . isArrowFunction ( param . parent ) && ts . isVariableDeclaration ( param . parent . parent ) ) {
1313 const variableDecl = param . parent . parent
1414 if ( variableDecl . type ?. getText ( ) . match ( / ( R e a c t \. ) ? F C / ) ) {
15- // handle interface
15+ // todo handle interface
1616 }
1717 }
1818 // general patterns
@@ -24,21 +24,12 @@ export default {
2424 if ( insertComma ) insertText = `, ${ insertText } `
2525 // alternatively only one snippetEdit could be used with tsFull.escapeSnippetText(insertText) + $0
2626 return {
27- edits : [
28- {
29- newText : insertText ,
30- span : {
31- length : 0 ,
32- start : insertPos ,
33- } ,
34- } ,
35- ] ,
3627 snippetEdits : [
3728 {
38- newText : '$0' ,
29+ newText : ` ${ tsFull . escapeSnippetText ( insertText ) } $0` ,
3930 span : {
4031 length : 0 ,
41- start : insertPos + insertText . length - 1 ,
32+ start : insertPos ,
4233 } ,
4334 } ,
4435 ] ,
@@ -48,3 +39,16 @@ export default {
4839 return
4940 } ,
5041} 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