Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
February 20, 2022 07:54 am GMT

TS tsc node

TypeScript
by SmartHR

===

npm i -g [email protected] 1 package, and audited 2 packages in 885msfound 0 vulnerabilities

npm i -g ts 4.3.5

===

ts

function sum(a:number, b: number) {  return a + b}console.log(sum(1, 2));

sum.ts ts

===

tsc js

tsc sum.ts

Image description

function sum(a, b) {    return a + b;}console.log(sum(1, 2));

tsc ts js

js VSCode OK

===

node js

node sum.js3

node js
tsc js
ts

===

ts

function sum(a:string, b: number) {  return a + b}console.log(sum(1, 2));


ts

===

VS Code

Image description

vscode

===

tsc

tsc sum.tssum.ts:5:17 - error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.5 console.log(sum(1, 2));                  ~Found 1 error.

tsc

====

ts-node ts

npm i -g ts-nodeadded 17 packages, and audited 18 packages in 2sfound 0 vulnerabilities

ts-node

npx ts-node sum.ts11

npx ts-node ts


Original Link: https://dev.to/kaede_io/ts-wo-tsc-to-node-dedong-kasu-18df

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To