I am using Angular 1.4, TypeScript 1.6 and CommonJS plugins.
I have three files in this module:
paginator.module.ts
paginator.service.ts
paginator.controller.ts
paginator.module.ts as follows:
import PaginatorService = require('./paginator.service');
import PaginatorCtrl = require('./paginator.controller');
var Paginator = angular.module('paginator', [])
.service('pageService', PaginatorService)
.controller('pageCtrl', PaginatorCtrl);
Here paginator.service.ts:
class PaginatorService {
currentPage: number;
pageCount: number;
pages: Array<Array<any>>;
constructor() {
this.currentPage = 0;
}
}
export = PaginatorService;
As paginator.controller.tsI put pageServicetogether with $scopeusing dependency injection, and I expect to see information about the type, when I give him the type PaginatorService.
class PaginatorController {
scope: ng.IScope;
pageService: PaginatorService;
constructor($scope: ng.IScope, pageService: PaginatorService) {
this.scope = $scope;
this.pageService = pageService;
}
export = PaginatorController;
However, I get the following error in atom-typescript:
TS Error: Cannot find name 'PaginatorService'.
What i tried
Adding another import statement to the file paginator.controller.jsfixes the problem (i.e. import PaginatorService = require('./paginator.service');). However, this seems redundant since I already require()d this service when setting up my Angular module.
tsc --declaration paginator.service.js , , .
Autogenerated d.ts file
declare class PaginatorService {
currentPage: number;
pageCount: number;
pages: Array<Array<any>>;
constructor();
}
export = PaginatorService;
- ( ?), , , 100 + Angular , CommonJS, .
: CommonJS + Angular + TypeScript, , Angular , ?
!