.d.ts files are called type declaration files. They exist for one purpose only: to describe the shape of an existing module and they only contain type information used for type checking.
Upon learning the basics of TypeScript, you unlock superpowers.
You automagically get warnings on potential errors, you get auto-completion out of the box in your code editor.
While seemingly magical, nothing with computers are.
So, what’s the trick here, TypeScript? In a clearer language, how does TypeScript know so much? How does it decide what API is correct or not? What methods are available on a certain object or class, and which aren’t?
The answer is less magical.


Think of a declaration file as containing all type information relating to a certain module. It contains no actual implementation, just type information.
These files have a .d.ts ending.
Your implementation files will either have .ts or .js endings to represent TypeScript or javascript files.
These declaration files have no implementations. They only contain type information and have a .d.ts file ending.
Now, Set up a new TypeScript project and dive into the .d.ts files to see how built-in objects like Math get their type definitions this is where TypeScript gets its deep understanding from.
Step 1) Create a new directory, and name it whatever’s appropriate.
Step 2) Now initialise a new project
npm init --yes
Step 3) Install TypeScript:
npm install typescript --save-dev
