I am creating user-based content and button show using ionic 5 and the firebase app. I am going through on post and implement it in my application.
I and using :
"firebase": "^8.1.1",
"@angular/fire": "^6.1.3",
Now I got errors in auth()
and firestore()
auth error is : Property 'auth' does not exist on type 'typeof import (TS-2339) AND firebase error is - Property 'firestore' does not exist on type 'typeof import
import { Component, OnInit } from "@angular/core";
import * as firebase from "firebase/app";
import "firebase/auth";
import "firebase/firestore";
@Component({
selector: "app-places",
templateUrl: "./posts.page.html",
styleUrls: ["./posts.page.scss"],
})
export class PlacesPage implements OnInit {
constructor() {}
//firestore = firebase.firestore();
public isAdmin = false;
ngOnInit() {
//Property 'auth' does not exist on type 'typeof import
firebase.auth().onAuthStateChanged((user) => {
if (user) {
firebase
.firestore() //Property 'firestore' does not exist on type 'typeof import
.doc(`s/${user.id}`)
.get()
.then((userProfileSnapshot) => {
this.isAdmin = userProfileSnapshot.data().isAdmin;
});
}
});
}
}
Please review the documentation for importing Firebase SDKs using a module bundler. Starting with Firebase SDK version 8.0.0, you now must import like this:
import firebase from "firebase/app";
import "firebase/auth";
import "firebase/firestore";
Notice that * as
is no longer part of the import in this version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With