Node runs the ts code:

  • npm install -g typescript
  • npm install -g ts-node
  • npm install -g ts-node
  • node demo.js
function add({ first, second }: { first: number; second: number }) :number {
  return first + second;
}


const func1: (str: string) = > number = (str) = > {
  return parseInt(str, 10);
};

const func = (str: string): number= > {
  return parseInt(str);
};

const arr: (number | string)[] = ["1".2.3];
Copy the code