fix: extends ElementHandle to Nodes (#8552)

* fix: extends `ElementHandle` to `Node`s (#8552)
This commit is contained in:
jrandolf
2022-07-06 09:05:37 +02:00
committed by GitHub
parent b49d530d73
commit 5ff205dc8b
93 changed files with 597 additions and 1095 deletions

View File

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

View File

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