Skip to content

Step 1 - Pre-requisites

Course: More Typescript APIs - chapter 1

Before you go through this module, make sure you’ve gone through basic typescript classes. You understand interfaces , types and how typescript is used in a simple Node.js application

If you understand the following code, you’re good to go!

interface User {
name: string;
age: number;
}
function sumOfAge(user1: User, user2: User) {
return a.age + b.age;
};
// Example usage
const result = sumOfAge({
name: "harkirat",
age: 20
}, {
name: "raman",
age: 21
});
console.log(result); // Output: 9

To recap, if you want to start a Typescript project locally, please do the following -

  1. Initialize TS
Terminal window
npx tsc --init
  1. Change tsconfig as per your needs. Usually changing rootDir and outDir is a good idea
Terminal window
{
"rootDir": "./src",
"outDir": "./dist"
}