After installing VS Code, I am struggling to figure out how to compile TypeScript code in VSCODE.
Some resources mention that VSCODE includes a "stable" version of TypeScript, while others suggest installing TypeScript separately. When I try to write the following simple code in a sample.ts file:
// sample.ts
function add(x: number, y: number): number {
return x + y;
}
console.log(add(2,2)); // 4
I encounter this error:
[Running] ts-node "i:\UserData\Ted\Documents\typescript-test\sample.ts" 'ts-node' is not recognized as an internal or external command, operable program or batch file.
How can I resolve this issue? Does VS Code come with TypeScript installed for compiling and running code? If so, what step am I missing, and if not, how do I address it?
I have used npm to install TypeScript (located in C:\Users\Ted\AppData\Roaming\npm\node_modules\typescript).