Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc Update: How to declare firestore in nodejs Typescript? #129

Open
Kayes-Islam opened this issue May 25, 2020 · 4 comments
Open

Doc Update: How to declare firestore in nodejs Typescript? #129

Kayes-Islam opened this issue May 25, 2020 · 4 comments

Comments

@Kayes-Islam
Copy link

Kayes-Islam commented May 25, 2020

The readme says:

With Typescript:

import * as geofirex from 'geofirex';
const geo = geofirex.init(firebase);

But where is firebase coming from? I have:

import * as admin from 'firebase-admin';
import * as geofirex from 'geofirex';
const app = admin.initializeApp();
//const geo = geofirex.init(app); // causing error, see below

When I do:
const geo = geofirex.init(app);
I get:

Argument of type 'App' is not assignable to parameter of type 'typeof firebase'.
Type 'App' is missing the following properties from type 'typeof firebase': registerVersion, setLogLevel, onLog, app, and 6 more.ts(2345)

How do I init geofirex in typescript for nodejs?

@skibaalex
Copy link

your app is not initialized correctly.
you need to provide a firebase config object

@Kayes-Islam
Copy link
Author

@muc1 The config is optional. See here: https://firebase.google.com/docs/admin/setup#initialize-without-parameters

Nevertheless, however I initialise the app, with or without config, the problem I have is that I don't know how to initialise the geofirex.

@BrDrawolf
Copy link

@Kayes-Islam Yeah, is nothing related to the config, faced this same issue a couple of days ago deploying functions to firebase. The way I resolved it and works without problem is doing the require-way as is in the readme for the admin-sdk, like this in typescript:

import * as admin from 'firebase-admin';
import {GeoFireClient} from "geofirex";

admin.initializeApp();
const geo: GeoFireClient = require('geofirex').init(admin);

Hope it helps! 👌

@Kayes-Islam
Copy link
Author

Thanks @BrDrawolf, your answer has solved this issue for me.

I still think it's an issue/improvement if we could use the typescript import without having to require(). I'll leave the issue open for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants