[英]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.我使用 Playwright 和 Typescript。 messagesData.successAddToCartMessage
is string entry from a JSON file. messagesData.successAddToCartMessage
是 JSON 文件中的字符串条目。 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:我不知道为什么我在最后一行得到这个 eslint 错误:
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.我不知道为什么会发生这个故障,但我需要重新启动 VS Code,然后错误就消失了:/ 非常烦人,我必须说。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.