angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

'collection' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.

Open navodikakarunasingha opened this issue 3 years ago • 1 comments
trafficstars

Version info

Angular: 13.1.0

Firebase: 9.4.0

AngularFire: 7.2.0

Other (e.g. Ionic/Cordova, Node, browser, operating system):

How to reproduce these conditions

Error occurs with the code given in the Readme.md

Debug output

** Errors in the JavaScript console ** 'collection' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. const collection = collection(firestore, 'items');

Block-scoped variable 'collection' used before its declaration. const collection = collection(firestore, 'items');

** Output from firebase.database().enableLogging(true); **

** Screenshots **

Expected behavior

No error

Actual behavior

Fail to compile

navodikakarunasingha avatar Jan 26 '22 04:01 navodikakarunasingha

Looks to be this line here: const collection = collection(firestore, 'items');

There are 2 variables named collection within the same scope. You are importing the angular/fire collection and using it to initialize a new variable with the same name. I think this is causing the error because the compiler thinks there is only 1 collection but there are 2.

JazzyMichael avatar Feb 02 '22 14:02 JazzyMichael