mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: extends ElementHandle to Nodes (#8552)
* fix: extends `ElementHandle` to `Node`s (#8552)
This commit is contained in:
@@ -19,15 +19,15 @@ declare const handle: ElementHandle;
|
||||
|
||||
{
|
||||
{
|
||||
expectType<ElementHandle<HTMLAnchorElement>[]>(await handle.$$('a'));
|
||||
expectNotType<ElementHandle<Element>[]>(await handle.$$('a'));
|
||||
expectType<Array<ElementHandle<HTMLAnchorElement>>>(await handle.$$('a'));
|
||||
expectNotType<Array<ElementHandle<Element>>>(await handle.$$('a'));
|
||||
}
|
||||
{
|
||||
expectType<ElementHandle<HTMLDivElement>[]>(await handle.$$('div'));
|
||||
expectNotType<ElementHandle<Element>[]>(await handle.$$('div'));
|
||||
expectType<Array<ElementHandle<HTMLDivElement>>>(await handle.$$('div'));
|
||||
expectNotType<Array<ElementHandle<Element>>>(await handle.$$('div'));
|
||||
}
|
||||
{
|
||||
expectType<ElementHandle<Element>[]>(await handle.$$('some-custom'));
|
||||
expectType<Array<ElementHandle<Element>>>(await handle.$$('some-custom'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {expectAssignable, expectNotAssignable, expectType} from 'tsd';
|
||||
import {expectNotAssignable, expectNotType, expectType} from 'tsd';
|
||||
import {ElementHandle} from '../lib/esm/puppeteer/common/ElementHandle.js';
|
||||
import {JSHandle} from '../lib/esm/puppeteer/common/JSHandle.js';
|
||||
|
||||
@@ -61,16 +61,16 @@ declare const handle2: JSHandle<{test: number}>;
|
||||
{
|
||||
{
|
||||
expectType<JSHandle<number>>(await handle2.getProperty('test'));
|
||||
expectNotAssignable<JSHandle<string>>(await handle2.getProperty('test'));
|
||||
expectNotType<JSHandle<unknown>>(await handle2.getProperty('test'));
|
||||
}
|
||||
{
|
||||
expectType<JSHandle<unknown>>(
|
||||
await handle2.getProperty('key-doesnt-exist')
|
||||
);
|
||||
expectAssignable<JSHandle<string>>(
|
||||
expectNotType<JSHandle<string>>(
|
||||
await handle2.getProperty('key-doesnt-exist')
|
||||
);
|
||||
expectAssignable<JSHandle<number>>(
|
||||
expectNotType<JSHandle<number>>(
|
||||
await handle2.getProperty('key-doesnt-exist')
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user