Tslint: can't use Array in firebase.firestore.CollectionReference | firebase.firestore.Query why ?

Created on 29 Aug 2018  路  5Comments  路  Source: palantir/tslint

 const list = this.afs.collection( 'City').ref;
let queryCollection: firebase.firestore.CollectionReference | firebase.firestore.Query &  Array = list;
for (let _i = 0; _i < this.data.areaList.length; _i++) {

            if (this.data.areaList) {  queryCollection[_i] = queryCollection.where('areaList', '==', this.data.areaList[_i]);

          }
            console.log(this.data.areaList[_i]);
      }

Note: can't use let only const why and how to change bug ?
I wanna use let queryCollection .

Question

All 5 comments

Array: You must specify the type of the array, like string[] for example.
Const: You will be allowed to use let instead of const, after you have a statement that assigns a new value:

let queryCollection = something;
queryCollection = somethingElse;

I can't because I will get snapshot of multiple Method this is example I have more one for loop
and I need get specific data .

array = [ ];
queryCollection .get().then(snapshot => {
          snapshot.forEach(action => {
            array .push(action.data());

           console.log(array );
          }); });

Note: my website need advanced filter :)

@Omar-Qalei the array is actually a const in your original code sample--you never modify the array reference itself. modifying items _in_ the array does not a new array make, so the const is correct.

(fwiw, i will rewrite code obsessively to avoid using let variables. the results are almost always worth it for legibility and maintainability.)

yes please help me , I'm first time create website.
I used mat-select type multiple and text input in advanced filter.
I need advanced filter such as
https://jo.opensooq.com/en/ajloun/real-estate-for-sale/apartments-for-sale

@Omar-Qalei sorry, this is not the place for advice on building web apps. the internet (especially StackOverflow) is full of useful information in this domain. best of luck!

Was this page helpful?
0 / 5 - 0 ratings