Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flattening TypeScript typings or interfaces?

As a TypeScript developer, I have become too used to "Duplicate identifier" issues when working with .d.ts files.

Most recently, this occurred because I needed both the typings (.d.ts files) of Angular 2, and Parse.

Angular 2 doesn't distribute their .d.ts files through DefinitelyTyped, so I had to fetch Angular 2 through NPM which includes the source files as well.

Now, Parse's .d.ts files come from DefinitelyTyped. Fine - so far, so good.

The issue then arises because both of these libraries depend on Node JS typings. The Node JS typings of Parse are located in the typings folder, whereas the Node JS typings of Angular 2 are located in a subfolder under node_modules/angular2.

This gives me a huge amount of duplicate identifier issues when compiling.

So, the big question(s)

  • Can I flatten .d.ts files so that it doesn't have duplicates somehow?
  • Can I somehow make the TypeScript compiler ignore duplicate interface definitions?
like image 879
Mathias Lykkegaard Lorenzen Avatar asked Dec 31 '15 12:12

Mathias Lykkegaard Lorenzen


1 Answers

There is no official tool to flatten .d.ts files or any other I'm aware of. There are many reported issues for your (or similar) problem:

  • typings from angular2 conflict with project typings
  • Type definition conflict with jQuery TSD
  • Conflict between Mocha and Jasmine typings.
  • Error on $ in angular-protractor.d.ts

Angular team is working on the issue.

As a workaround, I would simply comment out ///<reference> comments that cause your errors and wait for a bugfix.

like image 50
Martin Vseticka Avatar answered Sep 24 '22 15:09

Martin Vseticka