I'm playing around with TypeScript in a command-line NodeJS project, working through Advent of Code problems. For day 2, I started with:
day2.ts
export function* lineToNumbers(line: string): Iterable<number> {
console.log(`line = "${line}"`);
const parts = line.trim().split(/[Sa-b]\s+/);
for (const part of parts) {
yield Number(part);
}
}
And a Mocha unit test for this:
day2-test.ts
import * as day2 from "./day2";
describe("day2.lineToNumbers()", () => {
it("empty or whitespace string returns empty arrayS", () => {
assert.equal(Array.from(day2.lineToNumbers("")), []);
assert.equal(Array.from(day2.lineToNumbers(" ")), []);
});
});
When I run the main program, the debugger will hit a breakpoint in the TS source just fine, but when I try to debug the (failing) unit test, breakpoints don't get hit. I'm guessing the unit test runner just executes the generated .js file directly and doesn't handle source maps correctly.
Is there a way to bludgeon Visual Studio into just letting me debug an all-TS project correctly?