[英]Flattening TypeScript typings or interfaces?
As a TypeScript developer, I have become too used to "Duplicate identifier" issues when working with .d.ts
files. 作为TypeScript开发人员,在使用
.d.ts
文件时,我已经习惯了“重复标识符”问题。
Most recently, this occurred because I needed both the typings ( .d.ts
files) of Angular 2, and Parse. 最近发生这种情况是因为我需要两个Angular 2和Parse的
.d.ts
( .d.ts
文件)。
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. Angular 2不会通过
DefinitelyTyped
分发他们的.d.ts
文件,因此我必须通过NPM获取Angular 2,其中包括源文件。
Now, Parse's .d.ts
files come from DefinitelyTyped
. 现在,Parse的
.d.ts
文件来自DefinitelyTyped
。 Fine - so far, so good. 很好 - 到目前为止,非常好。
The issue then arises because both of these libraries depend on Node JS typings. 之所以出现这个问题是因为这两个库都依赖于Node JS的类型。 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
. Parse的Node JS类型位于
typings
文件夹中,而Angular 2的Node JS类型位于node_modules/angular2
下的子文件夹中。
This gives me a huge amount of duplicate identifier issues when compiling. 这在编译时给了我大量的重复标识符问题。
.d.ts
files so that it doesn't have duplicates somehow? .d.ts
文件,以便它不会以某种方式重复吗? There is no official tool to flatten .d.ts
files or any other I'm aware of. 没有官方工具来
.d.ts
文件或我知道的任何其他文件。 There are many reported issues for your (or similar) problem: 针对您(或类似)问题报告的问题很多:
Angular team is working on the issue . Angular团队正在研究这个问题 。
As a workaround, I would simply comment out ///<reference>
comments that cause your errors and wait for a bugfix. 作为一种解决方法,我只会注释掉导致错误的
///<reference>
注释并等待错误修复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.