I appreciate that this is likely a naive question, however I am trying to find my way in the dark and the documentation from Microsoft really isn't as intuitive as I need it to be, since I've never worked with either Visual Studio Code or TypeScript before.
Visual Studio Code > Help > About
references Node.js 12.14.1 - I'm not sure if it's telling me that it has included that in its own install or if it needs that to work properlyI have written and saved a basic .ts
file:
// my-first-typescript.ts
const myConst: number = 22;
console.log(myConst / 2);
If I now run Visual Studio Code > Terminal > New Terminal
and I enter:
tsc my-first-typescript.ts
a console pops up on Windows 7 asking:
Choose the program you want to use to open this file
Obviously the Terminal is trying to open tsc.js
and it doesn't know how.
This is where I'm stuck.
Is there any way to execute tsc.js
without having Node.js
installed? (I'm guessing not?)
But then, hasn't Visual Studio Code already installed itself with Node.js
? (If not, what's the Node.js 12.14.1 it refers to?)
I'm trying as much as possible to avoid downloading and installing Node.js
and npm
.
If I absolutely have to, then I will.
But it's a lot to download just to be able to run the TypeScript Compiler (tsc
) in Visual Studio Code.
You have to install typescript into your environment. And yes you need node installed.
After install node/npm you can install typescript with
npm install -g typescript
After that you can call the compiler tsc
, That will just convert the file from .ts
to .js
If you want to run it, I recommend to install ts-node
then you can do
ts-node myFile.ts