Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make $ and $$ selectors generic #6883

Merged
merged 4 commits into from Mar 25, 2021
Merged

fix: make $ and $$ selectors generic #6883

merged 4 commits into from Mar 25, 2021

Conversation

jackfranklin
Copy link
Collaborator

This means, much like TS's in built querySelector type, you can now do:

const listItems = page.$$<HTMLLIElement>('ul li');

And/or:

const h2 = page.$<HTMLHeadingElement>('h2');

And the return value will be of type ElementHandle<T>|null, where T
is the type you provided. By default T is an Element, so you don't
have to provide this if you don't care as a consumer about the exact
type you get back.

This means, much like TS's in built `querySelector` type, you can now do:

```ts
const listItems = page.$$<HTMLLIElement>('ul li');
```

And/or:

```ts
const h2 = page.$<HTMLHeadingElement>('h2');
```

And the return value will be of type `ElementHandle<T>|null`, where `T`
is the type you provided. By default `T` is an `Element`, so you don't
have to provide this if you don't care as a consumer about the exact
type you get back.
@jackfranklin jackfranklin enabled auto-merge (squash) February 17, 2021 11:16
@jackfranklin jackfranklin merged commit b349c91 into main Mar 25, 2021
@jackfranklin jackfranklin deleted the generic-$ branch March 25, 2021 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants