Urigo / meteor-angular2.0-socially

https://www.angular-meteor.com/tutorials/socially/
170 stars 120 forks source link

Property 'requestPhoneVerification' does not exist on type 'typeof Accounts'. #178

Closed tafelito closed 8 years ago

tafelito commented 8 years ago

@dotansimha How do you solve this typing issues? I know they are just warnings and do not affect the code, but I wasn't sure how to declare the module in this case, because the package okland:accounts-phone is an extension of the meteor accounts-base. I tried the following with no success

declare module 'meteor/accounts-base' {

  interface AccountsObject {
    requestPhoneVerification(phone: string, callback: (err:any) => void);
    verifyPhone(phone: string, code: string, callback: (err:any) => void);
    isPhoneVerified(): boolean;
  }

  export const Accounts: AccountsObject;
}

Thanks

dotansimha commented 8 years ago

It's simple, you just need to make sure that you create the new typings as it was defined before.

In this case, the original typings or meteor/accounts-base defines Accounts as module inside the exported module, and then inside the functions are defined. In this way, you can extend the module and add the missing functions.

So in order to solve that issue, add a new file or append to ./typings.d.ts file the following:

declare module 'meteor/accounts-base' {
  module Accounts {
    function requestPhoneVerification(phoneNumber: string, callback?: Function): void;
    function verifyPhone(phoneNumber: string, code: string, callback?: Function): void;
  }
}

I am keeping the issue open until I'll fix it in the tutorial :)

Thanks for noticing @tafelito !

dotansimha commented 8 years ago

Fixed in the commits and soon will be updated in the tutorial.

Thanks @tafelito !

tafelito commented 8 years ago

Awesome, thanks @dotansimha! there is no need to declare API functions that are not being used, likeisPhoneVerified, right?

dotansimha commented 8 years ago

You don't have to add them.

Ayesha17 commented 6 years ago

@dotansimha i have been added this code but there is an error occur of can not find meteor/accounts-base. What can I do ?