压扁打字稿分型或接口? [英] Flattening TypeScript typings or interfaces?

查看:137
本文介绍了压扁打字稿分型或接口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为打字稿开发人员,我已经成为了 .d.ts 文件时也使用复制标识的问题。

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

最近,发生这种情况,因为我需要的角2,并解析这两个分型( .d.ts 文件)。

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

2角通过 DefinitelyTyped 不分发他们的 .d.ts 文件,所以我只好取角2,通过NPM其中包括源文件也是如此。

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.

现在,解析的 .d.ts 文件来自 DefinitelyTyped 。精 - 到目前为止,那么好

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

问题随之出现,因为这两个库的依赖于节点JS分型。解析的节点JS分型位于分型文件夹,而折角2节点JS分型都位于一个子文件夹下 node_modules / angular2

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.


  • 我可以拼合 .d.ts 文件,因此它不会有重复不知何故?

  • 我可以以某种方式使打字稿编译器忽略重复接口定义?

  • 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?

推荐答案

有就是击败 .d.ts 文件或其他任何我所知道的没有官方的工具。有许多报告的问题,您(或类似)的问题:

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

角队工作的问题

作为一种变通方法,我只是注释掉 ///<参考方式>引起你的错误,等待bug修正注释

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

这篇关于压扁打字稿分型或接口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆