Firebaseui-web: Typescript definition

Created on 22 Mar 2017  路  14Comments  路  Source: firebase/firebaseui-web

It will be nice to provide e.g.
https://github.com/firebase/firebaseui-web/tree/master/index.d.ts file.

The first version could look like:

declare module "firebaseui" {

  import firebase from 'firebase';

  interface IConfig {
    callbacks?: ICallbacks;
    credentialHelper?: auth.CredentialHelper;
    queryParameterForSignInSuccessUrl?: string;
    queryParameterForWidgetMode?: string;
    signInFlow?: 'redirect' | 'popup';
    signInOptions: Array<ISignInOption | string>;
    signInSuccessUrl?: string;
    tosUrl: string;
  }
  interface ICallbacks {
    signInSuccess?: (currentUser: firebase.User, credential?: firebase.auth.AuthCredential, redirectUrl?: string) => boolean;
    uiShown?: () => void;
  }
  interface ISignInOption {
    provider: string;
    scopes?: Array<string>;
    requireDisplayName?: boolean;
  }

  namespace auth {
    enum CredentialHelper { ACCOUNT_CHOOSER_COM, NONE }
    class AuthUI {
      constructor(auth: firebase.auth.Auth);
      start(containerCSSselector: string, config: IConfig);
    }
  }
}

Most helpful comment

The fix is out: https://github.com/firebase/firebaseui-web/releases/tag/v3.1.1
I checked that index.d.ts is in there.

All 14 comments

Any progress on this issue? Would be great to have typings! Especially since firebase itself already provides typings.

We're swamped at the moment with a lot of feature work. We welcome external contributions on this.

@bojeil-google I know you're busy and you're doing a great job--thanks!--but IMHO TS definition files should ship by default. Without them, you're essentially saying that no-one using this in a TS environment can follow the TS best practices of strict: true, unless I'm missing something. Meanwhile, I've hacked the above to provide a void return type for start to make TS happy when in strict mode, a GOOGLE_YOLO constant, disableAutoSignIn, etc.

Without them, you're essentially saying that no-one using this in a TS environment can follow the TS best practices of strict: true, unless I'm missing something.

@rtm strict: true prohibits you from using implicit any, but you can still explicitly declare things as any, no?

Just checking in way later, since I'm using Angular and have decided to pull out of AngularFire2 after being burned a couple times... Are there typings? Are we stuck hacking around if we use TS?

We have added the typescript definitions in v3.1.0. I haven't had a chance to confirm they work as expected.

@bojeil-google I do have v3.1.0 installed but it does look like the index.d.ts file isn't included if I look into the node_modules folder.

You are right. We actually added closure externs too, but neither is available. It is likely something related to the deployment script we use. We apologize about that. We'll fix it in the next release.

Hmm, I think we simply forgot to include the additional files here: https://github.com/firebase/firebaseui-web/blob/master/package.json#L5
If so, it should be an easy fix.

Great. Thanks for the update. In the meantime I copied the file manually from the repo and works as expected.

Cool. Thanks for confirming. The fix is on the way: https://github.com/firebase/firebaseui-web/pull/438

The fix is out: https://github.com/firebase/firebaseui-web/releases/tag/v3.1.1
I checked that index.d.ts is in there.

These typings are very helpful, but two are missing from the AuthUI class in index.d.ts.

I haven't taken time to dig into the code, but I'm fairly certain that the return types for start() and setConfig() should be void. Everything compiles successfully, but the lack of a stated return type in the index.d.ts causes loud and obnoxious diagnostics. Any chance I could persuade you to add those two return types at lines 70 and 71 of the index.d.ts file?

@jsshapiro The issue has been reported in issue #445. The fix will be in next release next week. Thanks

Was this page helpful?
0 / 5 - 0 ratings