C
C
Comnox2021-09-13 21:12:46
typescript
Comnox, 2021-09-13 21:12:46

TypeScript type error in computed method in Vue?

Good evening, I encountered such a problem that when returning a filtered array in a computed method consisting of ObjectOfCity, TS swears that I can specify bigCard as soon as any , although this is the same ObjectOfCity object

filteredBigCards(): ObjectOfCity[] {
      return this.filters.length
        ? this.bigCardsList.filter((bigCard: <b>any</b>) =>
            this.filters.find((filter: string) => bigCard.weather[`${filter}`])
          )
        : this.bigCardsList;
    }


613f9478187d1540687915.png

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ blizzard: boolean; cloudy: boolean; metorite: boolean; rainy: boolean; snowy: boolean; stormy: boolean; sunny: boolean; }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question