DEV Community

Discussion on: Typescript Compiler

Collapse
artoodeeto profile image
aRtoo

So what is .d.ts I was always bothered by that but never really searched it until now. lols.

Collapse
ajitsinghkaler profile image
Ajit Singh Author

The d.ts just store the types of various variables as the js file cannot store variable types.

stackoverflow.com/questions/212472...

Collapse
artoodeeto profile image
aRtoo

I was just reading this too. thanks. This is to support some old JS code so they will have type annotations right? that's how I understand it.

Thread Thread
ajitsinghkaler profile image
Ajit Singh Author • Edited on

How actually typescript uses the .d.ts file I still have to understand that so giving a perfect answer to you an answer at this point will not be right. Once I will read and understand that I'll post that.

With my current info, I think you a little off. It's actually when you transfer your code as js files as in the compiled version of your code. It is in js form so, typescript has no way of knowing the different types that are there in the code. So, the d.ts are also sent in these builds so that the typescript knows what are the type of different js variables and objects. It can be old code new code etc.