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

References #1348.
This commit is contained in:
Dmitry Gozman 2020-03-18 15:19:58 -07:00 committed by GitHub
parent bfcffbb377
commit a1929e20f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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>);