I am trying to create a simple snippet that allows me to create JS Constructors. So far, what I have is
"class constructor": {
"prefix": "class",
"body": [
"class ${1:ClassName} {",
"\t\tconstructor({${2:thisName}: ${2}}) {",
"\t\t\tthis.${2} = ${2}",
"\t}",
"}"
],
"description": "class constructor template"
},
This works as expected, but what I am trying to see if it is possible to add multiple entries which also creates a new line for this
, but in this case, the snippet runs its course once I fill in the details for $2{thisName}
. What I am hoping for is the ability to add multiple key value pairs.
So instead of it ending at:
class ClassName {
constructor({ thisName: thisName}) {
this. thisName = thisName
}
}
I would like to be able to add other items so that it looks like; where a new line for this.another = another
is created automatically.
class ClassName {
constructor({ thisName: thisName, another: another}) {
this. thisName = thisName
this.another = another // this is create
}
}
The ${3}..
doesn't work here because there could be any amount of items.