angularjs - typescript complains about call signature when testing $componentController -
i trying test angular 1.5 component, typescript throwing red in console.
(17,27): error ts2349: cannot invoke expression type lacks call signature. type 'icomponentoptions' has no compatible call signatures. phantomjs 2.1.1 (windows 8 0.0.0) component: recipecontainer should have defined component failed
am including files incorrectly? (i'm using webpack compile).
am missing type definition?
any appreciated, been scratching head hours now.
spec file:
import * angular 'angular'; import 'angular-mocks'; import { recipecontainer } './recipe-container.component'; import { recipes } '../recipe-store'; describe('component: recipecontainer', () => { let $componentcontroller: ng.icomponentoptions; beforeeach(angular.mock.module('app')); beforeeach(angular.mock.inject((_$componentcontroller_: ng.icomponentoptions) => { $componentcontroller = _$componentcontroller_; })); it('should have defined component', () => { const bindings = { recipes }; const component = $componentcontroller('recipecontainer', null, bindings); //webstorm underlines line expect(component).tobedefined(); }); });
component.ts:
class recipecontainercontroller implements ng.icomponentcontroller { constructor(private $log: ng.ilogservice) { } $oninit() { this.$log.info('inside oninit'); } } export const recipecontainer: ng.icomponentoptions = { bindings: { recipes: '<' }, controller: recipecontainercontroller, template: '<div>hello</div>' };
$componentcontroller
has icomponentcontrollerservice
type. not icomponentoptions
. if use wrong type on variable, can expect typescript type system complain.
it should be
beforeeach(angular.mock.inject((_$componentcontroller_: ng.icomponentcontrollerservice) => { ...
Comments
Post a Comment