In my file named hw.ts
, the code is as follows:
function greeter(x: string) {
return "Hello" + x;
}
let u = "John";
document.body.innerHTML = greeter(u);
When I try to run it using Start without debugging
in VSCode, I get an error message:
Cannot launch program 'hw.ts' because corresponding JavaScript cannot be found.
To fix this, I compiled the file from the command line:
tsc hw.ts
Now that I have the hw.js
in the same folder, I tried running it again with Start without debugging
but got the same error message. Is there a way to compile and run TypeScript programs directly from within VSCode? What am I missing?
(My PATH
includes node
so it should be accessible to VSCode)