I am following this guide: https://v4.chriskrycho.com/2018/typing-your-ember-update-part-1.html
Here I have a service, which only have one function findAllContacts:
export default class ContactPicker extends Service {
findAllContacts(): Promise<Contact[]> {
return Promise.resolve(getContact());
}
}
declare module '@ember/service' {
interface Registry {
'contact-picker': ContactPicker;
}
}
and a phonebook component:
import Component from '@ember/component';
import Computed from "@ember/object/computed";
import ContactPicker from '../services/contact-picker';
import { inject as service } from '@ember/service';
export default class PhonebookView extends Component {
contactPicker: Computed<ContactPicker> = service('contact-picker');
didInsertElement() {
let contacts = this.contactPicker.findAllContacts(); //error
}
};
but I got typescript error when call this.contactPicker.findAllContacts(): Property 'findAllContacts' does not exist on type 'ComputedProperty'.ts(2339)
how to inject service with Typescript?
Aucun commentaire:
Enregistrer un commentaire