如何解决重复标识符“ by”错误?

时间:2019-01-31 22:41:11

标签: angular node-modules

我正在使用DomSanitizer类进行一些测试。我使用git checkout -- .撤消了所有更改,并收到以下控制台错误:

我签出到另一个git分支,错误仍然存​​在。

这是我的规格

Angular CLI: 6.2.8
Node: 8.12.0
OS: win32 x64
Angular: 6.1.10
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.8.8
@angular-devkit/build-angular     0.8.8
@angular-devkit/build-optimizer   0.8.8
@angular-devkit/build-webpack     0.8.8
@angular-devkit/core              0.8.8
@angular-devkit/schematics        0.8.8
@angular/cli                      6.2.8
@ngtools/webpack                  6.2.8
@schematics/angular               0.8.8
@schematics/update                0.8.8
rxjs                              6.2.2
typescript                        2.9.2
webpack                           4.16.4

这是错误

ERROR in node_modules/@angular/core/src/sanitization/security.d.ts(32,3): error TS2300: Duplicate identifier 'by'.
node_modules/@angular/platform-browser/src/security/dom_sanitization_service.d.ts(83,31): error TS2720: Class 'DomSanitizer' incorrectly implements class 'Sanitizer'. Did you mean to extend 'Sanitizer' and inherit its members as a subclass?
  Property 'by' is missing in type 'DomSanitizer'.

我在项目的任何地方都没有使用DomSanitizer,所以我不理解为什么在运行ng serve时会出现此错误

node_modules/@angular/platform-browser/src/security/dom_sanitization_service.d.ts包含以下内容:

export declare abstract class DomSanitizer implements Sanitizer {

我的文本编辑器抱怨implements,我改成extends

我收到新的错误消息:

ERROR in node_modules/@angular/core/src/sanitization/security.d.ts(32,3): error TS2300: Duplicate identifier 'by'.

这是node_modules/@angular/core/src/sanitization/security.d.ts

的内容
export declare abstract class Sanitizer {
  by: any;
  by: any;
    abstract sanitize(context: SecurityContext, value: {} | string | null): string | null;
}

它两次包含by: any属性,所以我删除了一个,它像一个超级按钮一样工作。

有人可以向我解释为什么会这样吗?我不明白为什么node_modules文件的内容可能突然改变。

1 个答案:

答案 0 :(得分:0)

节点模块可以由任何人编写(和发布)。这意味着模块的作者可以随时更新或删除它,而无需发出警告。

这很可能与git有关。有关更多信息,请参见Line Endings: Git merge creates duplicates without conflict