admin管理员组

文章数量:1327945

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;
                      });
                  }
                });
       
        }
       }
  

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;
                      });
                  }
                });
       
        }
       }
  
Share edited Dec 1, 2020 at 17:29 Pritesh Bhoi asked Dec 1, 2020 at 10:26 Pritesh BhoiPritesh Bhoi 1,0964 gold badges16 silver badges38 bronze badges 2
  • Please edit the question to show which version of the firebase module you're using. It will be in your package.json. – Doug Stevenson Commented Dec 1, 2020 at 16:09
  • @DougStevenson I update question. Thanks – Pritesh Bhoi Commented Dec 1, 2020 at 17:30
Add a ment  | 

1 Answer 1

Reset to default 9

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.

本文标签: javascriptfirebase and auth property does not exist in Ionic and FirebaseStack Overflow