Why define a definition (.d.ts) with Typescript - Angular2?

I have already seen other SO questions. But still confused in my question.

I have seen many examples of that use Jquery(js), Toastr(js) toastr without typing and other library JSdirectly angular2 app, without using the type definition (.d.ts), and they work great.

So, Bulgaria 1) basically, what wins or loses is going and not coming with a type definition file?

2) Angular2 files are also javascript files. So how are their type definition files?

Note. I have not tried using NPM, so I don’t know if all the related files are added t.dsto the folder typingswhen you actually install Angualr2 package.

+4
source share
1 answer

Typescript Definition files contain information about the type of code written in Javascript.

Javascript does not contain type information, so Typescript cannot magically retrieve this information. To solve this problem, definition files are created that tell Typescript what types are used there.

So, you can use third-party libraries without a definition file, but you will lose the type security that Typescript offers.

, jQuery, IDE intellisense/auto API jQuery. , Typescript , .

Typescript , Typescript.

+10

All Articles