Angular 2 The supplied parameters do not match any target call signature (spec.ts)

I am creating an Angular2 application using Angular2 Cli. I have a notification.component that has such a constructor

constructor(private _elRef: ElementRef) {}

When I create (start npm) I get this error

...angular2/tmp/broccoli_type_script_compiler-input_base_path-wKrIZXNv.tmp/0/src/app/notifications/notifications.component.spec.ts (10, 21): Supplied parameters do not match any signature of call target

The notifications.component.spec.ts file created by angular cli looks like this

import { By }           from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { addProviders, async, inject } from '@angular/core/testing';
import { NotificationsComponent } from './notifications.component';

describe('Component: Notifications', () => {
 it('should create an instance', () => {
 let component = new NotificationsComponent();
 expect(component).toBeTruthy();
 });
});

However, if I build without a constructor parameter, everything works fine. If I add this parameter after the build, everything will work fine.

What am I missing?

+4
source share
2 answers

Look at this line let component = new NotificationsComponent();.

NotificationsComponent, ElementRef.

, .

+1

, , temp, , , , notification.component.ts : "constructor (private _elRef: any = ElementRef) {}" , ,

0

Source: https://habr.com/ru/post/1649095/


All Articles