类型 '(Promise<Response> | Promise<void>)[]' 的参数不能分配给类型 '(Promise<void> | Promise



我有这个变量-一个承诺数组-(Promise<Response> | Promise<void>)[]:

const promises = [
this.page.waitForResponse(
(response) =>
response.url().includes('/my-account/addressform') &&
response.status() === ResponseCode.SUCCESS
),
this.page.waitForURL(/.*/delivery-address/add$/),
];  

但是当我像这样定义接收数组的函数时

private async loginAgain(promises: (Promise<Response> | Promise<void>)[]) {...} 

然后我从编译器得到错误:

Argument of type '(Promise<Response> | Promise<void>)[]' is not assignable to parameter of type '(Promise<void> | Promise<Response>)[]'.
Type 'Promise<Response> | Promise<void>' is not assignable to type 'Promise<void> | Promise<Response>'.
Type 'Promise<Response>' is not assignable to type 'Promise<void> | Promise<Response>'.
Type 'Promise<Response>' is not assignable to type 'Promise<void>'.
Type 'Response' is not assignable to type 'void'.ts(2345)

我该如何解决这个问题?promises参数的正确类型应该是什么?

我有两个不同的回答:D
我需要的是来自剧作家的一个。

import { Response } from '@playwright/test';

对不起!

最新更新