Search code examples
typescript-eslintfaker.js

Unsafe member access .toString on an `any` value @typescript-eslint/no-unsafe-member-access


I'm getting the following error on line 3 (id: faker.unique(().....):

"Unsafe member access .toString on an any value @typescript-eslint/no-unsafe-member-access"

I understand why I am getting the error but I am not sure how to fix it. Any suggestion would be appreciated :) Thanks in advance.

export const mockFinance = (): FinanceData => (
    {
        id: faker.unique(() => faker.datatype.number({ min: 1, max: 10000 })).toString() as Scalars['ID'],
        monthlyPrice: faker.commerce.price() as Maybe<Scalars['Float']>
    }
);

Solution

  • That problem was that I was missing the types for faker. I needed to install them.

    npm i --save @types/faker