I am getting below error please help- its simple line code "console.log("hi")" ; ERROR: Found 1 error in new.ts:1 PS D:\tspgm\typescriptPgms> tsc . ew.ts PS D:\tspgm\typescriptPgms> tsc . ew.js error TS6504: File 'new.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? The file is in the program because: Root file specified for compilation
In PS D:\tspgm\typescriptPgms> tsc . ew.js you try to compile a javascript source file by using a typescript compiler.. This is not possible because javascript code does NOT need compiling.. Javascript code needs a Javascript Runtime Environment like V8 in google's chrome browser or node.js for execution. Typescript code on the other hand needs compiling. What you should do, provided that you have installed node.js in your computer is : 1st execute console command tsc . ew.ts (the typescript compiler (tsc) generates the respective javascript source file named new.js from the typescript source file named new.ts) . 2nd execute console command node . ew.js (to execute the javascript source file.) Hope this helps. You can also install ts-node which will compile & execute in one command .. Here is a link to help you out www.educative.io/answers/how-to-execute-the-typescript-file-using-the-command-line
👌
I am getting below error please help- its simple line code "console.log("hi")" ;
ERROR:
Found 1 error in new.ts:1
PS D:\tspgm\typescriptPgms> tsc .
ew.ts
PS D:\tspgm\typescriptPgms> tsc .
ew.js
error TS6504: File 'new.js' is a JavaScript file. Did you mean to enable the 'allowJs' option?
The file is in the program because:
Root file specified for compilation
In PS D:\tspgm\typescriptPgms> tsc .
ew.js you try to compile a javascript source file by using a typescript compiler.. This is not possible because javascript code does NOT need compiling.. Javascript code needs a Javascript Runtime Environment like V8 in google's chrome browser or node.js for execution. Typescript code on the other hand needs compiling. What you should do, provided that you have installed node.js in your computer is : 1st execute console command tsc .
ew.ts (the typescript compiler (tsc) generates the respective javascript source file named new.js from the typescript source file named new.ts) . 2nd execute console command node .
ew.js (to execute the javascript source file.) Hope this helps. You can also install ts-node which will compile & execute in one command .. Here is a link to help you out
www.educative.io/answers/how-to-execute-the-typescript-file-using-the-command-line