How to solve "Unsafe call of an `any` typed value." in Eslint?

Viewed 2765

I'm getting an error when trying to loop through an array. When using a condition inside my ForEach I get the following error:

(parameter) treat: {
    [x: string]: unknown;
}
Object is of type 'unknown'.

Unsafe call of an `any` typed value.

Inside my function that ends up generating this error:

const companies = ref<HttpState>({
  data: [],
  meta: {},
  loading: false,
})

function getRowsNumberCount(filter: string, totalPages: number | undefined){
  if(!filter){
    return totalPages
  }
  let count = 0

  companies.value.data.forEach(treat => {    

    if(treat.name.includes(filter)){
      ++count
    }
  })
  return count
}

I'm new to typescript, but I believe it may be something with the typing of my data, I've already made some changes but I haven't had success.
Here is the data typing:

export type PaginationResponse<T = Record<string, unknown>[]> = { meta: Meta, data: T}

export type HttpState = PaginationResponse & { loading: boolean }
1 Answers
type Treat = { name: string }

const companies = ref<HttpState<Treat>>({
  data: [],
  meta: {},
  loading: false,
})

export type PaginationResponse<T = Record<string, unknown>[]> = { meta: Meta, data: T}

export type HttpState<T> = PaginationResponse<T> & { loading: boolean }

Now typescript should know what kind of array data is

Related