/** * @license * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import * as puppeteerCore from 'puppeteer-core'; /** * @fileoverview Lighthouse should be compatible with puppeteer and puppeteer-core even though the types can be slightly different between the two packages. * Anytime we want to use a Puppeteer type within Lighthouse, we should pull the union type from here rather than one of the packages directly. */ type IfNotAny = [T & 0] extends [1] ? never : T; declare module Puppeteer { // @ts-ignore Puppeteer is an optional dependency. `IfNotAny` will handle the `any` type if it's not installed. export type Browser = puppeteerCore.Browser | IfNotAny; // @ts-ignore Puppeteer is an optional dependency. `IfNotAny` will handle the `any` type if it's not installed. export type Page = puppeteerCore.Page | IfNotAny; // @ts-ignore Puppeteer is an optional dependency. `IfNotAny` will handle the `any` type if it's not installed. export type CDPSession = puppeteerCore.CDPSession | IfNotAny; // @ts-ignore Puppeteer is an optional dependency. `IfNotAny` will handle the `any` type if it's not installed. export type Connection = puppeteerCore.Connection | IfNotAny; } export default Puppeteer;