错误TS2315:类型'ElementRef'不是通用的。吴蚂蚁设计

时间:2019-03-14 17:19:46

标签: angular typescript ng-zorro-antd

某些内容: 角度版本:5.2.0

""@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0", "rxjs": "^5.5.6","

我正在尝试安装Ng Ant Design。我了解最新版本可能基于Angular 7构建,因此我采用了以前的版本。

"ng-zorro-antd": "1.8.1"

我在Angular CDK上遇到错误,所以我故意安装了

"@angular/cdk": "^5.2.0",
"@angular/material": "^5.2.0"

但是我仍然遇到这些错误

`ERROR in node_modules/ng-zorro-antd/node_modules/@angular/cdk/observers/typings/observe-content.d.ts(26,22): error TS2315: Type 'ElementRef' is not generic.

node_modules/ng-zorro-antd/node_modules/@angular/cdk/observers/typings/observe-content.d.ts(60,65): error TS2315: Type 'ElementRef' is not generic. node_modules/ng-zorro-antd/node_modules/@angular/cdk/overlay/typings/position/connected-position-strategy.d.ts(33,106): error TS2315: Type 'ElementRef' is not generic. node_modules/ng-zorro-antd/node_modules/@angular/cdk/a11y/typings/focus-monitor/focus-monitor.d.ts(117,30): error TS2315: Type 'ElementRef' is not generic. node_modules/ng-zorro-antd/node_modules/@angular/cdk/a11y/typings/focus-trap/focus-trap.d.ts(118,30): error TS2315: Type 'ElementRef' is not generic. node_modules/ng-zorro-antd/drawer/nz-drawer-ref.d.ts(1,28): error TS2307: Cannot find module 'rxjs/index'.

package-lock.json文件显示了此内容,因此我也尝试安装了“ @ angular / cdk”:“ 6.4.7”,但是得到相同的错误。

"ng-zorro-antd": {
  "version": "1.8.1",
  "resolved": "https://registry.npmjs.org/ng-zorro-antd/-/ng-zorro-antd-1.8.1.tgz",
  "integrity": "sha512-XNEwzt535/rILb/tEEwYBd2Ex4B4BwH7dzlbJAcpZZnN2tbIJYGNUiwbHo/o6t41Fv0qAgF/zmIlI0wQH+U7yA==",
  "requires": {
    "@angular/cdk": "^6.0.0",
    "@ant-design/icons-angular": "^1.0.1",
    "date-fns": "^1.29.0",
    "tslib": "^1.9.0"
  },
  "dependencies": {
    "@angular/cdk": {
      "version": "6.4.7",
      "resolved": "https://registry.npmjs.org/@angular/cdk/-/cdk-6.4.7.tgz",
      "integrity": "sha512-18x0U66fLD5kGQWZ9n3nb75xQouXlWs7kUDaTd8HTrHpT1s2QIAqlLd1KxfrYiVhsEC2jPQaoiae7VnBlcvkBg==",
      "requires": {
        "tslib": "^1.7.1"
      }
    }
  }
}

1 个答案:

答案 0 :(得分:0)

您有两个选择:

  • 将Angular依赖项升级到版本7并安装新的NgZorro
  • 将NgZorro降级到0.7.1版以获得与Angular 5.x兼容的版本

有关其依赖性历史记录https://github.com/NG-ZORRO/ng-zorro-antd/blob/0.7.1/package.json

,请参阅package.json。