summaryrefslogtreecommitdiffstats
path: root/remote/test/puppeteer/test-d
diff options
context:
space:
mode:
Diffstat (limited to 'remote/test/puppeteer/test-d')
-rw-r--r--remote/test/puppeteer/test-d/CommonEventEmitter.test-d.ts19
-rw-r--r--remote/test/puppeteer/test-d/ElementHandle.test-d.ts1025
-rw-r--r--remote/test/puppeteer/test-d/JSHandle.test-d.ts84
-rw-r--r--remote/test/puppeteer/test-d/NodeFor.test-d.ts157
-rw-r--r--remote/test/puppeteer/test-d/puppeteer.test-d.ts13
5 files changed, 1298 insertions, 0 deletions
diff --git a/remote/test/puppeteer/test-d/CommonEventEmitter.test-d.ts b/remote/test/puppeteer/test-d/CommonEventEmitter.test-d.ts
new file mode 100644
index 0000000000..581b248b8a
--- /dev/null
+++ b/remote/test/puppeteer/test-d/CommonEventEmitter.test-d.ts
@@ -0,0 +1,19 @@
+// eslint-disable-next-line no-restricted-imports
+import {EventEmitter as NodeEventEmitter} from 'node:events';
+
+import {expectAssignable} from 'tsd';
+
+import type {CommonEventEmitter, EventEmitter, EventType} from 'puppeteer';
+
+declare const emitter: EventEmitter<Record<EventType, any>>;
+
+{
+ {
+ expectAssignable<CommonEventEmitter<Record<EventType, any>>>(
+ new NodeEventEmitter()
+ );
+ }
+ {
+ expectAssignable<CommonEventEmitter<Record<EventType, any>>>(emitter);
+ }
+}
diff --git a/remote/test/puppeteer/test-d/ElementHandle.test-d.ts b/remote/test/puppeteer/test-d/ElementHandle.test-d.ts
new file mode 100644
index 0000000000..469150933b
--- /dev/null
+++ b/remote/test/puppeteer/test-d/ElementHandle.test-d.ts
@@ -0,0 +1,1025 @@
+import {expectNotType, expectType} from 'tsd';
+
+import type {ElementHandle} from 'puppeteer';
+
+declare const handle: ElementHandle;
+
+{
+ {
+ {
+ expectType<ElementHandle<HTMLAnchorElement> | null>(await handle.$('a'));
+ expectNotType<ElementHandle<Element> | null>(await handle.$('a'));
+ }
+ {
+ expectType<ElementHandle<HTMLAnchorElement> | null>(
+ await handle.$('a#id')
+ );
+ expectNotType<ElementHandle<Element> | null>(await handle.$('a#id'));
+ }
+ {
+ expectType<ElementHandle<HTMLAnchorElement> | null>(
+ await handle.$('a.class')
+ );
+ expectNotType<ElementHandle<Element> | null>(await handle.$('a.class'));
+ }
+ {
+ expectType<ElementHandle<HTMLAnchorElement> | null>(
+ await handle.$('a[attr=value]')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('a[attr=value]')
+ );
+ }
+ {
+ expectType<ElementHandle<HTMLAnchorElement> | null>(
+ await handle.$('a:psuedo-class')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('a:pseudo-class')
+ );
+ }
+ {
+ expectType<ElementHandle<HTMLAnchorElement> | null>(
+ await handle.$('a:func(arg)')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('a:func(arg)')
+ );
+ }
+ }
+ {
+ {
+ expectType<ElementHandle<HTMLDivElement> | null>(await handle.$('div'));
+ expectNotType<ElementHandle<Element> | null>(await handle.$('div'));
+ }
+ {
+ expectType<ElementHandle<HTMLDivElement> | null>(
+ await handle.$('div#id')
+ );
+ expectNotType<ElementHandle<Element> | null>(await handle.$('div#id'));
+ }
+ {
+ expectType<ElementHandle<HTMLDivElement> | null>(
+ await handle.$('div.class')
+ );
+ expectNotType<ElementHandle<Element> | null>(await handle.$('div.class'));
+ }
+ {
+ expectType<ElementHandle<HTMLDivElement> | null>(
+ await handle.$('div[attr=value]')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div[attr=value]')
+ );
+ }
+ {
+ expectType<ElementHandle<HTMLDivElement> | null>(
+ await handle.$('div:psuedo-class')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div:pseudo-class')
+ );
+ }
+ {
+ expectType<ElementHandle<HTMLDivElement> | null>(
+ await handle.$('div:func(arg)')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div:func(arg)')
+ );
+ }
+ }
+ {
+ {
+ expectType<ElementHandle<Element> | null>(await handle.$('some-custom'));
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('some-custom#id')
+ );
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('some-custom.class')
+ );
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('some-custom[attr=value]')
+ );
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('some-custom:pseudo-class')
+ );
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('some-custom:func(arg)')
+ );
+ }
+ }
+ {
+ {
+ expectType<ElementHandle<Element> | null>(await handle.$(''));
+ }
+ {
+ expectType<ElementHandle<Element> | null>(await handle.$('#id'));
+ }
+ {
+ expectType<ElementHandle<Element> | null>(await handle.$('.class'));
+ }
+ {
+ expectType<ElementHandle<Element> | null>(await handle.$('[attr=value]'));
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$(':pseudo-class')
+ );
+ }
+ {
+ expectType<ElementHandle<Element> | null>(await handle.$(':func(arg)'));
+ }
+ }
+ {
+ {
+ expectType<ElementHandle<HTMLAnchorElement> | null>(
+ await handle.$('div > a')
+ );
+ expectNotType<ElementHandle<Element> | null>(await handle.$('div > a'));
+ }
+ {
+ expectType<ElementHandle<HTMLAnchorElement> | null>(
+ await handle.$('div > a#id')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div > a#id')
+ );
+ }
+ {
+ expectType<ElementHandle<HTMLAnchorElement> | null>(
+ await handle.$('div > a.class')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div > a.class')
+ );
+ }
+ {
+ expectType<ElementHandle<HTMLAnchorElement> | null>(
+ await handle.$('div > a[attr=value]')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div > a[attr=value]')
+ );
+ }
+ {
+ expectType<ElementHandle<HTMLAnchorElement> | null>(
+ await handle.$('div > a:psuedo-class')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div > a:pseudo-class')
+ );
+ }
+ {
+ expectType<ElementHandle<HTMLAnchorElement> | null>(
+ await handle.$('div > a:func(arg)')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div > a:func(arg)')
+ );
+ }
+ }
+ {
+ {
+ expectType<ElementHandle<HTMLDivElement> | null>(
+ await handle.$('div > div')
+ );
+ expectNotType<ElementHandle<Element> | null>(await handle.$('div > div'));
+ }
+ {
+ expectType<ElementHandle<HTMLDivElement> | null>(
+ await handle.$('div > div#id')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div > div#id')
+ );
+ }
+ {
+ expectType<ElementHandle<HTMLDivElement> | null>(
+ await handle.$('div > div.class')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div > div.class')
+ );
+ }
+ {
+ expectType<ElementHandle<HTMLDivElement> | null>(
+ await handle.$('div > div[attr=value]')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div > div[attr=value]')
+ );
+ }
+ {
+ expectType<ElementHandle<HTMLDivElement> | null>(
+ await handle.$('div > div:psuedo-class')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div > div:pseudo-class')
+ );
+ }
+ {
+ expectType<ElementHandle<HTMLDivElement> | null>(
+ await handle.$('div > div:func(arg)')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div > div:func(arg)')
+ );
+ }
+ }
+ {
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('div > some-custom')
+ );
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('div > some-custom#id')
+ );
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('div > some-custom.class')
+ );
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('div > some-custom[attr=value]')
+ );
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('div > some-custom:pseudo-class')
+ );
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('div > some-custom:func(arg)')
+ );
+ }
+ }
+ {
+ {
+ expectType<ElementHandle<Element> | null>(await handle.$('div > #id'));
+ }
+ {
+ expectType<ElementHandle<Element> | null>(await handle.$('div > .class'));
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('div > [attr=value]')
+ );
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('div > :pseudo-class')
+ );
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('div > :func(arg)')
+ );
+ }
+ }
+ {
+ {
+ expectType<ElementHandle<HTMLAnchorElement> | null>(
+ await handle.$('div > a')
+ );
+ expectNotType<ElementHandle<Element> | null>(await handle.$('div > a'));
+ }
+ {
+ expectType<ElementHandle<HTMLAnchorElement> | null>(
+ await handle.$('div > a#id')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div > a#id')
+ );
+ }
+ {
+ expectType<ElementHandle<HTMLAnchorElement> | null>(
+ await handle.$('div > a.class')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div > a.class')
+ );
+ }
+ {
+ expectType<ElementHandle<HTMLAnchorElement> | null>(
+ await handle.$('div > a[attr=value]')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div > a[attr=value]')
+ );
+ }
+ {
+ expectType<ElementHandle<HTMLAnchorElement> | null>(
+ await handle.$('div > a:psuedo-class')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div > a:pseudo-class')
+ );
+ }
+ {
+ expectType<ElementHandle<HTMLAnchorElement> | null>(
+ await handle.$('div > a:func(arg)')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div > a:func(arg)')
+ );
+ }
+ }
+ {
+ {
+ expectType<ElementHandle<HTMLDivElement> | null>(
+ await handle.$('div > div')
+ );
+ expectNotType<ElementHandle<Element> | null>(await handle.$('div > div'));
+ }
+ {
+ expectType<ElementHandle<HTMLDivElement> | null>(
+ await handle.$('div > div#id')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div > div#id')
+ );
+ }
+ {
+ expectType<ElementHandle<HTMLDivElement> | null>(
+ await handle.$('div > div.class')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div > div.class')
+ );
+ }
+ {
+ expectType<ElementHandle<HTMLDivElement> | null>(
+ await handle.$('div > div[attr=value]')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div > div[attr=value]')
+ );
+ }
+ {
+ expectType<ElementHandle<HTMLDivElement> | null>(
+ await handle.$('div > div:psuedo-class')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div > div:pseudo-class')
+ );
+ }
+ {
+ expectType<ElementHandle<HTMLDivElement> | null>(
+ await handle.$('div > div:func(arg)')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.$('div > div:func(arg)')
+ );
+ }
+ }
+ {
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('div > some-custom')
+ );
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('div > some-custom#id')
+ );
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('div > some-custom.class')
+ );
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('div > some-custom[attr=value]')
+ );
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('div > some-custom:pseudo-class')
+ );
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('div > some-custom:func(arg)')
+ );
+ }
+ }
+ {
+ {
+ expectType<ElementHandle<Element> | null>(await handle.$('div > #id'));
+ }
+ {
+ expectType<ElementHandle<Element> | null>(await handle.$('div > .class'));
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('div > [attr=value]')
+ );
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('div > :pseudo-class')
+ );
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.$('div > :func(arg)')
+ );
+ }
+ }
+}
+
+{
+ {
+ {
+ expectType<Array<ElementHandle<HTMLAnchorElement>>>(await handle.$$('a'));
+ expectNotType<Array<ElementHandle<Element>>>(await handle.$$('a'));
+ }
+ {
+ expectType<Array<ElementHandle<HTMLAnchorElement>>>(
+ await handle.$$('a#id')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(await handle.$$('a#id'));
+ }
+ {
+ expectType<Array<ElementHandle<HTMLAnchorElement>>>(
+ await handle.$$('a.class')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(await handle.$$('a.class'));
+ }
+ {
+ expectType<Array<ElementHandle<HTMLAnchorElement>>>(
+ await handle.$$('a[attr=value]')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('a[attr=value]')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLAnchorElement>>>(
+ await handle.$$('a:psuedo-class')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('a:pseudo-class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLAnchorElement>>>(
+ await handle.$$('a:func(arg)')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('a:func(arg)')
+ );
+ }
+ }
+ {
+ {
+ expectType<Array<ElementHandle<HTMLDivElement>>>(await handle.$$('div'));
+ expectNotType<Array<ElementHandle<Element>>>(await handle.$$('div'));
+ }
+ {
+ expectType<Array<ElementHandle<HTMLDivElement>>>(
+ await handle.$$('div#id')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(await handle.$$('div#id'));
+ }
+ {
+ expectType<Array<ElementHandle<HTMLDivElement>>>(
+ await handle.$$('div.class')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div.class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLDivElement>>>(
+ await handle.$$('div[attr=value]')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div[attr=value]')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLDivElement>>>(
+ await handle.$$('div:psuedo-class')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div:pseudo-class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLDivElement>>>(
+ await handle.$$('div:func(arg)')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div:func(arg)')
+ );
+ }
+ }
+ {
+ {
+ expectType<Array<ElementHandle<Element>>>(await handle.$$('some-custom'));
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('some-custom#id')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('some-custom.class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('some-custom[attr=value]')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('some-custom:pseudo-class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('some-custom:func(arg)')
+ );
+ }
+ }
+ {
+ {
+ expectType<Array<ElementHandle<Element>>>(await handle.$$(''));
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(await handle.$$('#id'));
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(await handle.$$('.class'));
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('[attr=value]')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$(':pseudo-class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(await handle.$$(':func(arg)'));
+ }
+ }
+ {
+ {
+ expectType<Array<ElementHandle<HTMLAnchorElement>>>(
+ await handle.$$('div > a')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(await handle.$$('div > a'));
+ }
+ {
+ expectType<Array<ElementHandle<HTMLAnchorElement>>>(
+ await handle.$$('div > a#id')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > a#id')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLAnchorElement>>>(
+ await handle.$$('div > a.class')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > a.class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLAnchorElement>>>(
+ await handle.$$('div > a[attr=value]')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > a[attr=value]')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLAnchorElement>>>(
+ await handle.$$('div > a:psuedo-class')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > a:pseudo-class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLAnchorElement>>>(
+ await handle.$$('div > a:func(arg)')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > a:func(arg)')
+ );
+ }
+ }
+ {
+ {
+ expectType<Array<ElementHandle<HTMLDivElement>>>(
+ await handle.$$('div > div')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > div')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLDivElement>>>(
+ await handle.$$('div > div#id')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > div#id')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLDivElement>>>(
+ await handle.$$('div > div.class')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > div.class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLDivElement>>>(
+ await handle.$$('div > div[attr=value]')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > div[attr=value]')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLDivElement>>>(
+ await handle.$$('div > div:psuedo-class')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > div:pseudo-class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLDivElement>>>(
+ await handle.$$('div > div:func(arg)')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > div:func(arg)')
+ );
+ }
+ }
+ {
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > some-custom')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > some-custom#id')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > some-custom.class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > some-custom[attr=value]')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > some-custom:pseudo-class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > some-custom:func(arg)')
+ );
+ }
+ }
+ {
+ {
+ expectType<Array<ElementHandle<Element>>>(await handle.$$('div > #id'));
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > .class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > [attr=value]')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > :pseudo-class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > :func(arg)')
+ );
+ }
+ }
+ {
+ {
+ expectType<Array<ElementHandle<HTMLAnchorElement>>>(
+ await handle.$$('div > a')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(await handle.$$('div > a'));
+ }
+ {
+ expectType<Array<ElementHandle<HTMLAnchorElement>>>(
+ await handle.$$('div > a#id')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > a#id')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLAnchorElement>>>(
+ await handle.$$('div > a.class')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > a.class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLAnchorElement>>>(
+ await handle.$$('div > a[attr=value]')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > a[attr=value]')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLAnchorElement>>>(
+ await handle.$$('div > a:psuedo-class')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > a:pseudo-class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLAnchorElement>>>(
+ await handle.$$('div > a:func(arg)')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > a:func(arg)')
+ );
+ }
+ }
+ {
+ {
+ expectType<Array<ElementHandle<HTMLDivElement>>>(
+ await handle.$$('div > div')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > div')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLDivElement>>>(
+ await handle.$$('div > div#id')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > div#id')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLDivElement>>>(
+ await handle.$$('div > div.class')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > div.class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLDivElement>>>(
+ await handle.$$('div > div[attr=value]')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > div[attr=value]')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLDivElement>>>(
+ await handle.$$('div > div:psuedo-class')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > div:pseudo-class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<HTMLDivElement>>>(
+ await handle.$$('div > div:func(arg)')
+ );
+ expectNotType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > div:func(arg)')
+ );
+ }
+ }
+ {
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > some-custom')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > some-custom#id')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > some-custom.class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > some-custom[attr=value]')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > some-custom:pseudo-class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > some-custom:func(arg)')
+ );
+ }
+ }
+ {
+ {
+ expectType<Array<ElementHandle<Element>>>(await handle.$$('div > #id'));
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > .class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > [attr=value]')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > :pseudo-class')
+ );
+ }
+ {
+ expectType<Array<ElementHandle<Element>>>(
+ await handle.$$('div > :func(arg)')
+ );
+ }
+ }
+}
+
+{
+ expectType<void>(
+ await handle.$eval(
+ 'a',
+ (element, int) => {
+ expectType<HTMLAnchorElement>(element);
+ expectType<number>(int);
+ },
+ 1
+ )
+ );
+ expectType<void>(
+ await handle.$eval(
+ 'div',
+ (element, int, str) => {
+ expectType<HTMLDivElement>(element);
+ expectType<number>(int);
+ expectType<string>(str);
+ },
+ 1,
+ ''
+ )
+ );
+ expectType<number>(
+ await handle.$eval(
+ 'a',
+ (element, value) => {
+ expectType<HTMLAnchorElement>(element);
+ return value;
+ },
+ 1
+ )
+ );
+ expectType<number>(
+ await handle.$eval(
+ 'some-element',
+ (element, value) => {
+ expectType<Element>(element);
+ return value;
+ },
+ 1
+ )
+ );
+ expectType<HTMLAnchorElement>(
+ await handle.$eval('a', element => {
+ return element;
+ })
+ );
+ expectType<unknown>(await handle.$eval('a', 'document'));
+}
+
+{
+ expectType<void>(
+ await handle.$$eval(
+ 'a',
+ (elements, int) => {
+ expectType<HTMLAnchorElement[]>(elements);
+ expectType<number>(int);
+ },
+ 1
+ )
+ );
+ expectType<void>(
+ await handle.$$eval(
+ 'div',
+ (elements, int, str) => {
+ expectType<HTMLDivElement[]>(elements);
+ expectType<number>(int);
+ expectType<string>(str);
+ },
+ 1,
+ ''
+ )
+ );
+ expectType<number>(
+ await handle.$$eval(
+ 'a',
+ (elements, value) => {
+ expectType<HTMLAnchorElement[]>(elements);
+ return value;
+ },
+ 1
+ )
+ );
+ expectType<number>(
+ await handle.$$eval(
+ 'some-element',
+ (elements, value) => {
+ expectType<Element[]>(elements);
+ return value;
+ },
+ 1
+ )
+ );
+ expectType<HTMLAnchorElement[]>(
+ await handle.$$eval('a', elements => {
+ return elements;
+ })
+ );
+ expectType<unknown>(await handle.$$eval('a', 'document'));
+}
+
+{
+ {
+ expectType<ElementHandle<HTMLAnchorElement> | null>(
+ await handle.waitForSelector('a')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.waitForSelector('a')
+ );
+ }
+ {
+ expectType<ElementHandle<HTMLDivElement> | null>(
+ await handle.waitForSelector('div')
+ );
+ expectNotType<ElementHandle<Element> | null>(
+ await handle.waitForSelector('div')
+ );
+ }
+ {
+ expectType<ElementHandle<Element> | null>(
+ await handle.waitForSelector('some-custom')
+ );
+ }
+}
diff --git a/remote/test/puppeteer/test-d/JSHandle.test-d.ts b/remote/test/puppeteer/test-d/JSHandle.test-d.ts
new file mode 100644
index 0000000000..fa7348d28e
--- /dev/null
+++ b/remote/test/puppeteer/test-d/JSHandle.test-d.ts
@@ -0,0 +1,84 @@
+import {expectNotAssignable, expectNotType, expectType} from 'tsd';
+
+import type {ElementHandle, JSHandle} from 'puppeteer';
+
+declare const handle: JSHandle;
+
+{
+ expectType<unknown>(await handle.evaluate('document'));
+ expectType<number>(
+ await handle.evaluate(() => {
+ return 1;
+ })
+ );
+ expectType<HTMLElement>(
+ await handle.evaluate(() => {
+ return document.body;
+ })
+ );
+ expectType<string>(
+ await handle.evaluate(() => {
+ return '';
+ })
+ );
+ expectType<string>(
+ await handle.evaluate((value, str) => {
+ expectNotAssignable<never>(value);
+ expectType<string>(str);
+ return '';
+ }, '')
+ );
+}
+
+{
+ expectType<JSHandle>(await handle.evaluateHandle('document'));
+ expectType<JSHandle<number>>(
+ await handle.evaluateHandle(() => {
+ return 1;
+ })
+ );
+ expectType<JSHandle<string>>(
+ await handle.evaluateHandle(() => {
+ return '';
+ })
+ );
+ expectType<JSHandle<string>>(
+ await handle.evaluateHandle((value, str) => {
+ expectNotAssignable<never>(value);
+ expectType<string>(str);
+ return '';
+ }, '')
+ );
+ expectType<ElementHandle<HTMLElement>>(
+ await handle.evaluateHandle(() => {
+ return document.body;
+ })
+ );
+}
+
+declare const handle2: JSHandle<{test: number}>;
+
+{
+ {
+ expectType<JSHandle<number>>(await handle2.getProperty('test'));
+ expectNotType<JSHandle<unknown>>(await handle2.getProperty('test'));
+ }
+ {
+ expectType<JSHandle<unknown>>(
+ await handle2.getProperty('key-doesnt-exist')
+ );
+ expectNotType<JSHandle<string>>(
+ await handle2.getProperty('key-doesnt-exist')
+ );
+ expectNotType<JSHandle<number>>(
+ await handle2.getProperty('key-doesnt-exist')
+ );
+ }
+}
+
+{
+ void handle.evaluate((value, other) => {
+ expectType<unknown>(value);
+ expectType<{test: number}>(other);
+ }, handle2);
+}
diff --git a/remote/test/puppeteer/test-d/NodeFor.test-d.ts b/remote/test/puppeteer/test-d/NodeFor.test-d.ts
new file mode 100644
index 0000000000..0a40b4e689
--- /dev/null
+++ b/remote/test/puppeteer/test-d/NodeFor.test-d.ts
@@ -0,0 +1,157 @@
+import {expectType, expectNotType} from 'tsd';
+
+import type {NodeFor} from 'puppeteer';
+
+declare const nodeFor: <Selector extends string>(
+ selector: Selector
+) => NodeFor<Selector>;
+
+{
+ {
+ expectType<HTMLTableRowElement>(
+ nodeFor(
+ '[data-testid="my-component"] div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div tbody tr'
+ )
+ );
+ expectNotType<Element>(
+ nodeFor(
+ '[data-testid="my-component"] div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div tbody tr'
+ )
+ );
+ }
+ {
+ expectType<HTMLAnchorElement>(nodeFor('a'));
+ expectNotType<Element>(nodeFor('a'));
+ }
+ {
+ expectType<HTMLAnchorElement>(nodeFor('a#ignored'));
+ expectNotType<Element>(nodeFor('a#ignored'));
+ }
+ {
+ expectType<HTMLAnchorElement>(nodeFor('a.ignored'));
+ expectNotType<Element>(nodeFor('a.ignored'));
+ }
+ {
+ expectType<HTMLAnchorElement>(nodeFor('a[ignored'));
+ expectNotType<Element>(nodeFor('a[ignored'));
+ }
+ {
+ expectType<HTMLAnchorElement>(nodeFor('a:ignored'));
+ expectNotType<Element>(nodeFor('a:ignored'));
+ }
+ {
+ expectType<HTMLAnchorElement>(nodeFor('ignored a'));
+ expectNotType<Element>(nodeFor('ignored a'));
+ }
+ {
+ expectType<HTMLAnchorElement>(nodeFor('ignored a#ignored'));
+ expectNotType<Element>(nodeFor('ignored a#ignored'));
+ }
+ {
+ expectType<HTMLAnchorElement>(nodeFor('ignored a.ignored'));
+ expectNotType<Element>(nodeFor('ignored a.ignored'));
+ }
+ {
+ expectType<HTMLAnchorElement>(nodeFor('ignored a[ignored'));
+ expectNotType<Element>(nodeFor('ignored a[ignored'));
+ }
+ {
+ expectType<HTMLAnchorElement>(nodeFor('ignored a:ignored'));
+ expectNotType<Element>(nodeFor('ignored a:ignored'));
+ }
+ {
+ expectType<HTMLAnchorElement>(nodeFor('ignored > a'));
+ expectNotType<Element>(nodeFor('ignored > a'));
+ }
+ {
+ expectType<HTMLAnchorElement>(nodeFor('ignored > a#ignored'));
+ expectNotType<Element>(nodeFor('ignored > a#ignored'));
+ }
+ {
+ expectType<HTMLAnchorElement>(nodeFor('ignored > a.ignored'));
+ expectNotType<Element>(nodeFor('ignored > a.ignored'));
+ }
+ {
+ expectType<HTMLAnchorElement>(nodeFor('ignored > a[ignored'));
+ expectNotType<Element>(nodeFor('ignored > a[ignored'));
+ }
+ {
+ expectType<HTMLAnchorElement>(nodeFor('ignored > a:ignored'));
+ expectNotType<Element>(nodeFor('ignored > a:ignored'));
+ }
+ {
+ expectType<HTMLAnchorElement>(nodeFor('ignored + a'));
+ expectNotType<Element>(nodeFor('ignored + a'));
+ }
+ {
+ expectType<HTMLAnchorElement>(nodeFor('ignored ~ a'));
+ expectNotType<Element>(nodeFor('ignored ~ a'));
+ }
+ {
+ expectType<HTMLAnchorElement>(nodeFor('ignored | a'));
+ expectNotType<Element>(nodeFor('ignored | a'));
+ }
+ {
+ expectType<HTMLAnchorElement>(
+ nodeFor('ignored ignored > ignored + ignored | a#ignore')
+ );
+ expectNotType<Element>(
+ nodeFor('ignored ignored > ignored + ignored | a#ignore')
+ );
+ }
+}
+{
+ {
+ expectType<Element>(nodeFor(''));
+ }
+ {
+ expectType<Element>(nodeFor('#ignored'));
+ }
+ {
+ expectType<Element>(nodeFor('.ignored'));
+ }
+ {
+ expectType<Element>(nodeFor('[ignored'));
+ }
+ {
+ expectType<Element>(nodeFor(':ignored'));
+ }
+ {
+ expectType<Element>(nodeFor('ignored #ignored'));
+ }
+ {
+ expectType<Element>(nodeFor('ignored .ignored'));
+ }
+ {
+ expectType<Element>(nodeFor('ignored [ignored'));
+ }
+ {
+ expectType<Element>(nodeFor('ignored :ignored'));
+ }
+ {
+ expectType<Element>(nodeFor('ignored > #ignored'));
+ }
+ {
+ expectType<Element>(nodeFor('ignored > .ignored'));
+ }
+ {
+ expectType<Element>(nodeFor('ignored > [ignored'));
+ }
+ {
+ expectType<Element>(nodeFor('ignored > :ignored'));
+ }
+ {
+ expectType<Element>(nodeFor('ignored + #ignored'));
+ }
+ {
+ expectType<Element>(nodeFor('ignored ~ #ignored'));
+ }
+ {
+ expectType<Element>(nodeFor('ignored | #ignored'));
+ }
+ {
+ expectType<Element>(
+ nodeFor('ignored ignored > ignored ~ ignored + ignored | #ignored')
+ );
+ }
+}
diff --git a/remote/test/puppeteer/test-d/puppeteer.test-d.ts b/remote/test/puppeteer/test-d/puppeteer.test-d.ts
new file mode 100644
index 0000000000..f7a45c0db4
--- /dev/null
+++ b/remote/test/puppeteer/test-d/puppeteer.test-d.ts
@@ -0,0 +1,13 @@
+import {expectType} from 'tsd';
+
+import puppeteer, {
+ type connect,
+ type defaultArgs,
+ type executablePath,
+ type launch,
+} from 'puppeteer';
+
+expectType<typeof launch>(puppeteer.launch);
+expectType<typeof connect>(puppeteer.connect);
+expectType<typeof defaultArgs>(puppeteer.defaultArgs);
+expectType<typeof executablePath>(puppeteer.executablePath);