Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(types): restore electron types (#5574)

Joel Einbinder180446d20f03
diff --git a/types/types.d.ts b/types/types.d.ts
index 3eaccaf8ef..661959f90b 100644
--- a/types/types.d.ts
+++ b/types/types.d.ts
@@ -7042,6 +7042,9 @@ type AccessibilityNode = {
export const selectors: Selectors;
export const devices: Devices & DeviceDescriptor[];
+//@ts-ignore this will be any if electron is not installed
+type ElectronType = typeof import('electron');
+
/**
* Electron application representation. You can use
* [electron.launch([options])](https://playwright.dev/docs/api/class-electron#electronlaunchoptions) to obtain the
@@ -7095,8 +7098,8 @@ export interface ElectronApplication {
* @param pageFunction Function to be evaluated in the worker context.
* @param arg Optional argument to pass to `pageFunction`.
*/
- evaluate<R, Arg>(pageFunction: PageFunctionOn<any, Arg, R>, arg: Arg): Promise<R>;
- evaluate<R>(pageFunction: PageFunctionOn<any, void, R>, arg?: any): Promise<R>;
+ evaluate<R, Arg>(pageFunction: PageFunctionOn<ElectronType, Arg, R>, arg: Arg): Promise<R>;
+ evaluate<R>(pageFunction: PageFunctionOn<ElectronType, void, R>, arg?: any): Promise<R>;
/**
* Returns the return value of `pageFunction` as a [JSHandle].
@@ -7117,8 +7120,8 @@ export interface ElectronApplication {
* @param pageFunction Function to be evaluated in the worker context.
* @param arg
*/
- evaluateHandle<R, Arg>(pageFunction: PageFunctionOn<any, Arg, R>, arg: Arg): Promise<SmartHandle<R>>;
- evaluateHandle<R>(pageFunction: PageFunctionOn<any, void, R>, arg?: any): Promise<SmartHandle<R>>;
+ evaluateHandle<R, Arg>(pageFunction: PageFunctionOn<ElectronType, Arg, R>, arg: Arg): Promise<SmartHandle<R>>;
+ evaluateHandle<R>(pageFunction: PageFunctionOn<ElectronType, void, R>, arg?: any): Promise<SmartHandle<R>>;
/**
* This event is issued when the application closes.
*/
diff --git a/utils/generate_types/overrides.d.ts b/utils/generate_types/overrides.d.ts
index f5468f14fa..a178ff1e7e 100644
--- a/utils/generate_types/overrides.d.ts
+++ b/utils/generate_types/overrides.d.ts
@@ -222,12 +222,15 @@ type AccessibilityNode = {
export const selectors: Selectors;
export const devices: Devices & DeviceDescriptor[];
+//@ts-ignore this will be any if electron is not installed
+type ElectronType = typeof import('electron');
+
export interface ElectronApplication {
- evaluate<R, Arg>(pageFunction: PageFunctionOn<any, Arg, R>, arg: Arg): Promise<R>;
- evaluate<R>(pageFunction: PageFunctionOn<any, void, R>, arg?: any): Promise<R>;
+ evaluate<R, Arg>(pageFunction: PageFunctionOn<ElectronType, Arg, R>, arg: Arg): Promise<R>;
+ evaluate<R>(pageFunction: PageFunctionOn<ElectronType, void, R>, arg?: any): Promise<R>;
- evaluateHandle<R, Arg>(pageFunction: PageFunctionOn<any, Arg, R>, arg: Arg): Promise<SmartHandle<R>>;
- evaluateHandle<R>(pageFunction: PageFunctionOn<any, void, R>, arg?: any): Promise<SmartHandle<R>>;
+ evaluateHandle<R, Arg>(pageFunction: PageFunctionOn<ElectronType, Arg, R>, arg: Arg): Promise<SmartHandle<R>>;
+ evaluateHandle<R>(pageFunction: PageFunctionOn<ElectronType, void, R>, arg?: any): Promise<SmartHandle<R>>;
}
export type AndroidElementInfo = {