VSC 1.43.2, TS 3.8.3, Node v13.11.0
With the default compilation target, TSC unrolls generator functions into switch statements. The interactive debugger can then step in and out of calls to a generator's next() method each time it's invoked.
However, when targeting JS compilation targets that preserve generator functions, the debugger can step into the call to create a generator, but stepping over inside the generator never causes the debugger to step out.
For example, if you break on the call to gen() in the sample file and then press F11 to step into the generator function, no amount of pressing F10 will step back out of it. The rest of the file will execute with the debugger still inside the scope of the generator. The behavior is the same if you break on a call to next() and press F11.
Is this a limitation of the VSC debugger, or is there some additional configuration I need to set for a more intuitive interactive debugging experience?
Launch config:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "some name",
"program": "${file}",
"outFiles": ["${workspaceFolder}/**/*.js"],
"runtimeArgs": ["--experimental-modules", "--es-module-specifier-resolution=node"],
"smartStep": true,
}
]
}
TS config:
{
"compilerOptions": {
"sourceMap": true,
"target": "ESNext"
},
}
Example TS file:
function* gen() {
for (let i = 0; i < 3; i++) {
yield i;
}
}
const x = gen();
const y = 2 + 2;
console.log(x.next());
console.log(x.next());
console.log(x.next());