tsc command output empty js file

Viewed 5435

I am learning Angular/Typescript and found my first issue. Don't even know how to ask it correctly. Searched it around and got nothing.

I have a main.ts file with this code

function myFunc(x,y){
    return x+y;
}

let num = 2;
const PI = 3.14;

When I do the command

tsc main.ts

It creates an empty file named main.js

In the video course I am watching, the generated file is populated with the corresponding javascript.

What should I do? Thanks in advance

5 Answers

I encountered a similar issue. I quickly realized that I haven't save the main.ts file on VS code by running:

cat main.ts

In that case, you are basically compiling an empty file. I guess the tutorial did not bother to mention that you should manually save your file.

You first need to save the file. (Ctrl + s). Otherwise compiler will compile an empty file.

So you should manually save the file.

Type in your IDE's terminal 'npm install -g eslint' save all, and reload project. Worked for me!

Make sure you save your main.ts file under "Open Editor" before running the node main.js in VS Code terminal. Hope this helps!

Related