Skip to content

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

feat(types): better types for nested handles (#1424)

Dmitry Gozmana1929e20f555
diff --git a/src/types.ts b/src/types.ts
index 3cad1b4aeb..a9ad12b55b 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -18,7 +18,8 @@ import * as js from './javascript';
import * as dom from './dom';
import Injected from './injected/injected';
-type Boxed<Args extends any[]> = { [Index in keyof Args]: Args[Index] | js.JSHandle<Args[Index]> };
+type BoxedArg<Arg> = js.JSHandle<Arg> | (Arg extends object ? { [Key in keyof Arg]: BoxedArg<Arg[Key]> } : Arg);
+type Boxed<Args extends any[]> = { [Index in keyof Args]: BoxedArg<Args[Index]> };
type PageFunction<Args extends any[], R = any> = string | ((...args: Args) => R | Promise<R>);
type PageFunctionOn<On, Args extends any[], R = any> = string | ((on: On, ...args: Args) => R | Promise<R>);
type PageFunctionWithInjected<On, Args extends any[], R = any> = string | ((injected: Injected, on: On, ...args: Args) => R | Promise<R>);