Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 5 ng-bootstrap Type 'ElementRef' is not generic err

I use angular 5 and ng-bootstrap in these versions:

  "private": true,
  "dependencies": {
    "@angular/animations": "^5.2.0",
    "@angular/common": "^5.2.0",
    "@angular/compiler": "^5.2.0",
    "@angular/core": "^5.2.0",
    "@angular/forms": "^5.2.0",
    "@angular/http": "^5.2.0",
    "@angular/platform-browser": "^5.2.0",
    "@angular/platform-browser-dynamic": "^5.2.0",
    "@angular/router": "^5.2.0",
    "@ng-bootstrap/ng-bootstrap": "^2.1.0",
    "angular-in-memory-web-api": "^0.5.4",
    "angular2-moment": "^1.9.0",
    "bootstrap": "^4.1.1",
    "core-js": "^2.4.1",
    "date-util": "^1.2.1",
    "material-icons": "^0.2.1",
    "ngx-bootstrap": "^3.0.0",
    "normalize.css": "^8.0.0",
    "rxjs": "^5.5.6",
    "zone.js": "^0.8.19"
  },

when I get ng serve has this error:

**

Failed to compile.

node_modules/@ng-bootstrap/ng-bootstrap/buttons/radio.d.ts(58,96): error TS2315: Type 'ElementRef' is not generic. node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-input.d.ts(121,67): error TS2315: Type 'ElementRef' is not generic. node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(115,208): error TS2315: Type 'ElementRef' is not generic. node_modules/@ng-bootstrap/ng-bootstrap/dropdown/dropdown.d.ts(12,45): error TS2315: Type 'ElementRef' is not generic. node_modules/@ng-bootstrap/ng-bootstrap/dropdown/dropdown.d.ts(29,45): error TS2315: Type 'ElementRef' is not generic. node_modules/@ng-bootstrap/ng-bootstrap/dropdown/dropdown.d.ts(37,44): error TS2315: Type 'ElementRef' is not generic. node_modules/@ng-bootstrap/ng-bootstrap/modal/modal-window.d.ts(13,40): error TS2315: Type 'ElementRef' is not generic.

like image 620
GustavoFraga Avatar asked Jun 10 '18 03:06

GustavoFraga


2 Answers

I had the same issue. So I unistalled the ng-bootstrap.

Then I reinstall it directly whit 2.0.0 version.

npm install --save @ng-bootstrap/[email protected]

like image 101
Azac Avatar answered Oct 17 '22 07:10

Azac


You need to use Angular 6.0.0 or later with ng-bootstrap >= 2.0.0. npm / yarn install should have given you warning during installation.

Reverting to ng-bootstrap 2.0.0 is not a solution as you will simply be stuck with this version of a library and won't receive updates / fixes.

To properly resolve this issue you need to either:

  • upgrade Angular to version 6.0.0 or later (recommended)
  • use lates ng-bootstrap still compatible with Angular 5.x (1.1.2)
like image 36
pkozlowski.opensource Avatar answered Oct 17 '22 07:10

pkozlowski.opensource