Repository: microsoft/playwright
File: utils/generate_types/overrides-test.d.ts (TypeScript)

Code before:
/**
 * Copyright (c) Microsoft Corporation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import type { APIRequestContext, Browser, BrowserContext, BrowserContextOptions, Page, LaunchOptions, ViewportSize, Geolocation, HTTPCredentials, Locator, APIResponse, PageScreenshotOptions } from 'playwright-core';
export * from 'playwright-core';

// @ts-ignore this will be any if react is not installed
type ReactCSSProperties = import('react').CSSProperties;
type FallbackCSSProperties = { [name: string]: string | number | undefined };
export type CSSProperties = keyof ReactCSSProperties extends string ? ReactCSSProperties : FallbackCSSProperties;

export type BlobReporterOptions = { outputDir?: string, fileName?: string };
export type ListReporterOptions = { printSteps?: boolean };
export type JUnitReporterOptions = { outputFile?: string, stripANSIControlSequences?: boolean, includeProjectInTestName?: boolean };
export type JsonReporterOptions = { outputFile?: string };
export type HtmlReporterOptions = {
  outputFolder?: string;
  open?: 'always' | 'never' | 'on-failure';
  host?: string;
  port?: number;
  attachmentsBaseURL?: string;
  title?: string;
  noSnippets?: boolean;
  noCopyPrompt?: boolean;
};

export type ReporterDescription = Readonly<
  ['blob'] | ['blob', BlobReporterOptions] |
  ['dot'] |
  ['line'] |
  ['list'] | ['list', ListReporterOptions] |
  ['github'] |
  ['junit'] | ['junit', JUnitReporterOptions] |
  ['json'] | ['json', JsonReporterOptions] |

Review comment (suggestion):
This should be something like `never` when react is missing to indicate the error. We don't want this signature to be used without react.

Code after:
/**
 * Copyright (c) Microsoft Corporation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import type { APIRequestContext, Browser, BrowserContext, BrowserContextOptions, Page, LaunchOptions, ViewportSize, Geolocation, HTTPCredentials, Locator, APIResponse, PageScreenshotOptions } from 'playwright-core';
export * from 'playwright-core';

// @ts-ignore ReactCSSProperties will be any if react is not installed
type ReactCSSProperties = import('react').CSSProperties;
export type CSSProperties = keyof ReactCSSProperties extends string ? ReactCSSProperties : never;

export type BlobReporterOptions = { outputDir?: string, fileName?: string };
export type ListReporterOptions = { printSteps?: boolean };
export type JUnitReporterOptions = { outputFile?: string, stripANSIControlSequences?: boolean, includeProjectInTestName?: boolean };
export type JsonReporterOptions = { outputFile?: string };
export type HtmlReporterOptions = {
  outputFolder?: string;
  open?: 'always' | 'never' | 'on-failure';
  host?: string;
  port?: number;
  attachmentsBaseURL?: string;
  title?: string;
  noSnippets?: boolean;
  noCopyPrompt?: boolean;
};

export type ReporterDescription = Readonly<
  ['blob'] | ['blob', BlobReporterOptions] |
  ['dot'] |
  ['line'] |
  ['list'] | ['list', ListReporterOptions] |
  ['github'] |
  ['junit'] | ['junit', JUnitReporterOptions] |
  ['json'] | ['json', JsonReporterOptions] |
  ['html'] | ['html', HtmlReporterOptions] |