Currently, I am working on an AngularJS framework (version 1.5.8) with the latest TypeScript files (version 2.8.0). However, after updating to the most recent TypeScript version, the code below is not compiling.
Implementation of Angular interface:
interface IPromise<T> {
/**
* Description of the IPromise interface methods and functionalities.
*/
}
ITemplate interface:
export interface ITemplateService {
/**
* Method for scrolling to a specific element.
* @param inputFieldId
* @param offset
* @param ms
* @returns {}
*/
getTemplates(dto?: TemplateFilterPostDto): ng.IPromise<TemplatesPagingModel>;
/**
* Function to set template groups as comma-separated values for list presentation
* @param template The template to use
*/
setTemplateGroupsAsCommaSeparated(template: TemplateModel): void;
}
The class that implements ITemplateService:
export default class TemplateService implements ITemplateService {
public static $inject = ["TemplateRepository", "$q", "MappingService"];
private initialTemplateFilter: ITemplateFilterPostDto = {
currentPage: 1,
group: null,
name: null,
totalResults: ConfigurationService.TOTAL_ROWS[0]
};
constructor(
public templateRepository: ITemplateRepository,
public $q: ng.IQService,
public mappingService: IMappingService) {
}
public getTemplates(dto?: ITemplateFilterPostDto): ng.IPromise<TemplatesPagingModel> {
const defer = this.$q.defer();
// Code logic for getting templates
return defer.promise;
}
public setTemplateGroupsAsCommaSeparated(template: TemplateModel): void {
// Logic for setting template groups as comma-separated values
}
}
Upon updating to TypeScript 2.8.0, the following error is encountered:
'Type 'IPromise<{}>' is not assignable to type 'IPromise'. Type '{}' is not assignable to type 'TemplatesPagingModel'. Property 'templates' is missing in type '{}'.