0

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 ?

Matthew Green
  • 10,161
  • 4
  • 36
  • 54
Jean-Baptiste
  • 1,552
  • 1
  • 19
  • 33

1 Answers1

1

Error message already gives you a hint

Property 'uuid' is missing in type '{ uiid: string; type: string; }'

declaration:

uuid: string = '00000';
 ^^

value:

uiid: "text",
 ^^
vpoverennov
  • 307
  • 3
  • 10