Skip to content

Commit

Permalink
fix: internal lazy params (#8982)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrandolf committed Sep 19, 2022
1 parent 7d69272 commit d504597
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/api/puppeteer.innerparams.md
Expand Up @@ -8,7 +8,7 @@ sidebar_label: InnerParams

```typescript
export declare type InnerParams<T extends unknown[]> = {
[K in keyof T]: FlattenHandle<FlattenLazyArg<FlattenHandle<T[K]>>>;
[K in keyof T]: FlattenHandle<T[K]>;
};
```

Expand Down
6 changes: 4 additions & 2 deletions src/common/IsolatedWorld.ts
Expand Up @@ -30,7 +30,7 @@ import {JSHandle} from './JSHandle.js';
import {LazyArg} from './LazyArg.js';
import {LifecycleWatcher, PuppeteerLifeCycleEvent} from './LifecycleWatcher.js';
import {TimeoutSettings} from './TimeoutSettings.js';
import {EvaluateFunc, HandleFor, NodeFor} from './types.js';
import {EvaluateFunc, HandleFor, InnerLazyParams, NodeFor} from './types.js';
import {createJSHandle, debugError, pageBindingInitString} from './util.js';
import {TaskManager, WaitTask} from './WaitTask.js';

Expand Down Expand Up @@ -559,7 +559,9 @@ export class IsolatedWorld {

waitForFunction<
Params extends unknown[],
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>
Func extends EvaluateFunc<InnerLazyParams<Params>> = EvaluateFunc<
InnerLazyParams<Params>
>
>(
pageFunction: Func | string,
options: {
Expand Down
9 changes: 8 additions & 1 deletion src/common/types.ts
Expand Up @@ -43,11 +43,18 @@ export type FlattenHandle<T> = T extends HandleOr<infer U> ? U : never;
*/
export type FlattenLazyArg<T> = T extends LazyArg<infer U> ? U : T;

/**
* @internal
*/
export type InnerLazyParams<T extends unknown[]> = {
[K in keyof T]: FlattenLazyArg<T[K]>;
};

/**
* @public
*/
export type InnerParams<T extends unknown[]> = {
[K in keyof T]: FlattenHandle<FlattenLazyArg<FlattenHandle<T[K]>>>;
[K in keyof T]: FlattenHandle<T[K]>;
};

/**
Expand Down

0 comments on commit d504597

Please sign in to comment.