To add two numbers in TypeScript, you can declare two variables with type number and then use the + operator to perform their addition:
index.ts109 chars6 lines
We first declare num1 and num2 variables of type number and assign them values of 5 and 10 respectively. Then, we declare the sum variable and assign it the value obtained by adding num1 and num2. Finally, we log the value of sum which should be 15.
gistlibby LogSnag