Type 'ElementRef' is not generic

Naeem picture Naeem · Apr 18, 2018 · Viewed 26.3k times · Source

I am working with a project using Material Component in Angular 5. I did update my Visual code but I don't know what happened. I am facing an issue "Type 'ElementRef' is not generic." I have been stuck on this issue since morning.

Error in this line

_inputElement: ElementRef<HTMLInputElement>;
constructor(toggleGroup: MatButtonToggleGroup, _changeDetectorRef: ChangeDetectorRef, _elementRef: ElementRef<HTMLInputElement>, _focusMonitor: FocusMonitor);

Answer

Sibeesh Venu picture Sibeesh Venu · Jun 10, 2018

I was getting the same error as above in ng-bootstrap in my Angular 5 application.

ERROR in node_modules/@ng-bootstrap/ng-bootstrap/buttons/radio.d.ts(58,96): error TS2315: Type 'ElementRef' is not generic.

I had 2.1.0 version in my package.json as "@ng-bootstrap/ng-bootstrap": "^2.1.0"

It seems like the version 2.1.0 is supported in later version, so decided to downgrade my package ng-bootstrap to "@ng-bootstrap/ng-bootstrap": "^1.1.0"

And then, when I run ng s, everything was working as expected.