auth0-ionic2-samples icon indicating copy to clipboard operation
auth0-ionic2-samples copied to clipboard

Using @types

Open lightheaded opened this issue 8 years ago • 0 comments

I'm really excited to use Auth0 in my ionic application, but it seems that this example is quite up to date. I don't think adding scripts to index.html is a valid approach.

What I'm trying to do is to get it working with DI. I have:

  1. installed auth0, auth0-lock, @types/auth0 and @types/auth0-lock modules
  2. import Auth0 from 'auth0'; and import Auth0Lock from 'auth0-lock'; in my user-session.ts provider and provide it in the app module via providers.
  3. I'm trying to inject it in the constructor, like
constructor(auth0: Auth0, lock: Auth0Lock) {}

Now I'm stuck. I'm unable to figure out how to initialise Auth0 and pass Auth0ClientOptions (http://definitelytyped.org/docs/auth0--auth0/interfaces/auth0clientoptions.html). This method gives me Cannot find name 'Auth0'. When I try to instantiate it in the injectable class

auth0 = new Auth0(this.auth0ClientOptions);

but then it's Cannot use 'new' with an expression whose type lacks a call or construct signature.

Could you update the example to use Dependency Injections and/or properly use typed libraries?

lightheaded avatar Oct 27 '16 19:10 lightheaded