Let's say I want to create a VSCode snippet for a typescript interface, one that looks like this:
interface MyInterface{
prop1: string;
prop2: string;
prop3: string
}
Now I could just create the following snippet:
"myinterface": {
"prefix": "myinterface",
"body": [
"interface MyInterface{ ",
" prop1: string; ",
" prop2: string;",
" prop3: string",
"}"
],
"description": "not smart interface creator"
}
But what if I wanted to have a prop4
, prop5
, or prop6
in my interface? Is there anyway to conditionally extend the snippet, so that by hitting Tab
I would be prompted to add another prop field to the interface with the format ${1:propX}: ${2:string};
?
Another use case is writing out an array:
const myArray = [val1, val2, val3]