Why do i need `typings.json` file in an Angular 2 project?

So, I’ve found this:

Any JavaScript libraries, such as jQuery, the Jasmine testing library, and Angular, extend the JavaScript environment with features and syntax that the TypeScript compiler doesn’t recognize natively. When the compiler doesn’t recognize something, it throws an error.

So, If we wrote a library which may use by other persons in their projects along with TypeScript, the TypeScript throws an error. To resolve it, we have to write the TypeScript type definition files (.d.ts files) in the library directory.

AngularJS along with most of the libraries already doing this.But, Libraries like “core-js” and “jasmine” do not include d.ts files in their npm packages. Fortunately, either their authors or community contributors have created separate .d.ts files for these libraries and published them in well-known locations. The typings tool can find and fetch these files for you.

So, we have to write typings.json file to get the correct type definition files to run the project smoothly.

Leave a Comment