DEV Community

Discussion on: Typescript Compiler

artoodeeto profile image

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.