types: allow readonly tuples to be used as ReporterDescription (#30387)

This makes it easier to create helper functions like:
```ts
function createReporter(options: MyOptions) {
  return ['my-reporter', options] as const
}
```

At the moment, such functions can't be passed to `reporters` because a
readonly array is not assignable to the expected mutable array.
Playwirght certainly doesn't require those arrays to be mutable so it
would make sense to relax this.
This commit is contained in:
Mateusz Burzyński 2024-04-17 02:39:11 +02:00 committed by GitHub
parent cda1c945af
commit 82aefd24db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View File

@ -18,7 +18,7 @@
import type { APIRequestContext, Browser, BrowserContext, BrowserContextOptions, Page, LaunchOptions, ViewportSize, Geolocation, HTTPCredentials, Locator, APIResponse, PageScreenshotOptions } from 'playwright-core';
export * from 'playwright-core';
export type ReporterDescription =
export type ReporterDescription = Readonly<
['blob'] | ['blob', { outputDir?: string, fileName?: string }] |
['dot'] |
['line'] |
@ -28,7 +28,8 @@ export type ReporterDescription =
['json'] | ['json', { outputFile?: string }] |
['html'] | ['html', { outputFolder?: string, open?: 'always' | 'never' | 'on-failure', host?: string, port?: number, attachmentsBaseURL?: string }] |
['null'] |
[string] | [string, any];
[string] | [string, any]
>;
type UseOptions<TestArgs, WorkerArgs> = Partial<WorkerArgs> & Partial<TestArgs>;

View File

@ -17,7 +17,7 @@
import type { APIRequestContext, Browser, BrowserContext, BrowserContextOptions, Page, LaunchOptions, ViewportSize, Geolocation, HTTPCredentials, Locator, APIResponse, PageScreenshotOptions } from 'playwright-core';
export * from 'playwright-core';
export type ReporterDescription =
export type ReporterDescription = Readonly<
['blob'] | ['blob', { outputDir?: string, fileName?: string }] |
['dot'] |
['line'] |
@ -27,7 +27,8 @@ export type ReporterDescription =
['json'] | ['json', { outputFile?: string }] |
['html'] | ['html', { outputFolder?: string, open?: 'always' | 'never' | 'on-failure', host?: string, port?: number, attachmentsBaseURL?: string }] |
['null'] |
[string] | [string, any];
[string] | [string, any]
>;
type UseOptions<TestArgs, WorkerArgs> = Partial<WorkerArgs> & Partial<TestArgs>;