Currently, I am a novice who is delving into the world of TypeScript. Here is a snippet of code that I have written:
let num: number = 123;
console.log(123);
However, when attempting to run this file using Node.js and saving it as test.ts
, I encounter the error message
SyntaxError: Unexpected token ':'
.
From my understanding, this is the correct way to specify the type of a variable in TypeScript, right? Just to provide some context, I am utilizing VSCode for my coding environment. Additionally, I have both Node.js and npm properly installed, along with TypeScript. I double-checked their versions as well. Despite scouring the internet, I could not find a solution to this seemingly trivial problem.
Could someone kindly point out what mistake I might be making?