Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
216 views
in Technique[技术] by (71.8m points)

typescript - Why do I get firebase namespace errors after upgrading to Angular 11

I have upgraded my project from Angular 10 -> 11.

After I have done that, I get errors like this:

enter image description here

I have imported firebase like this:

import firebase from '@firebase/app';
import '@firebase/database';
import '@firebase/firestore';
import '@firebase/auth';
import '@firebase/analytics';
import '@firebase/functions';
import '@firebase/storage';

Example where I get an error:

const firestoreDocRefs: firebase.firestore.DocumentReference[] = [];

and

analyticsRef: firebase.analytics.Analytics;

What has changed when going from Angular 10 -> 11 and how can I get the firebase namespace to work for me again?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

After some experimenting I found that this works:

import firebase from 'firebase/app';
import 'firebase/database';
import 'firebase/firestore';
import 'firebase/auth';
import 'firebase/analytics';
import 'firebase/functions';
import 'firebase/storage';

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...