-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Description
Version info
Angular: 13.2.5
Firebase: 10.1.4
AngularFire: 7.2.1
How to reproduce these conditions
Build the AngularFire Quickstart. https://github.com/angular/angularfire/blob/master/docs/install-and-setup.md
Step 7 fails.
Steps to set up and reproduce
This code is provided in the tutorial:
constructor(firestore: AngularFirestore) {
this.items = firestore.collection('items').valueChanges();
}
That produces this error message:
src/app/app.component.ts:29:12 - error TS2339: Property 'firestore' does not exist on type 'AppComponent'.
I can fix the problem with this code:
constructor(public firestore: AngularFirestore) {
this.items = firestore.collection('items').valueChanges();
}
Or with this code:
constructor(protected firestore: AngularFirestore) {
this.items = firestore.collection('items').valueChanges();
}
This also works:
constructor(private firestore: AngularFirestore) {
this.items = firestore.collection('items').valueChanges();
}
In other words, setting the constructor to public
, protected
, or private
works. Setting nothing throws an error.
Debug output
src/app/app.component.ts:29:12 - error TS2339: Property 'firestore' does not exist on type 'AppComponent'.
Expected behavior
Not setting this and setting public
should be the same, according to the TypeScript Handbook.
Actual behavior
Not setting this throws an error.
Metadata
Metadata
Assignees
Labels
No labels