简体   繁体   中英

Typescript - eslint error Unsafe argument of type 'any' assigned to a type

I have the following code:

import * as messagesData from '../../data/messages.json';
await test.step(
        'Add second product to the cart product listing page',
        async () => {
          await categoryPage.clickAddToCartBtn(1);
          const successMessage = categoryPage.getSuccessMessage();
          await expect(successMessage).toBeVisible();
          await expect(successMessage).toHaveText(
            messagesData.successAddToCartMessage
          );
        }
      );

I use Playwright and Typescript. messagesData.successAddToCartMessage is string entry from a JSON file. So why does it complain that this is of type any?
I am not sure why I get this eslint error in the last line:

Unsafe argument of type `any` assigned to a parameter of type `string | RegExp | (string | RegExp)[]` 

I have similar code a few lines below where it doesn't complain.
I am super confused. Please help!

I don't know why this glitch happened, but I needed to restart VS Code and then the error was gone:/ Very annoying, I must say.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM