Reputation: 1562
I am new to Angular 2, and Angular as well, and I am running into this issue related to promises.
I have this file name module.service.ts
import { Injectable } from '@angular/core';
import { Module } from './module.entity';
@Injectable()
export class ModuleService {
getModules(): Promise<Module[]> {
// TODO: Switch to a real service.
return Promise.resolve([{
uiid: "text",
type: "ahahaha"
}]);
}
}
Which call module.entity which contains this code:
export class Module {
uuid: string = '00000';
type: string = 'TextComponent';
// Maps ModuleSlots to modules
submodules: {[key: string]: [Module]} = {};
}
But running npm starts
returns this error to me:
Type 'Promise<{ uiid: string; type: string; }[]>' is not assignable to type 'Promise'. Type '{ uiid: string; type: string; }[]' is not assignable to type 'Module[]'. Type '{ uiid: string; type: string; }' is not assignable to type 'Module'. Property 'uuid' is missing in type '{ uiid: string; type: string; }'.
Can anybody gives me a hint about what's not working ?
Upvotes: 0
Views: 3868
Reputation: 308
Error message already gives you a hint
Property 'uuid' is missing in type '{ uiid: string; type: string; }'
declaration:
uuid: string = '00000';
^^
value:
uiid: "text",
^^
Upvotes: 1