From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../test/puppeteer/test-d/ElementHandle.test-d.ts | 1024 ++++++++++++++++++++ remote/test/puppeteer/test-d/JSHandle.test-d.ts | 83 ++ remote/test/puppeteer/test-d/NodeFor.test-d.ts | 156 +++ remote/test/puppeteer/test-d/puppeteer.test-d.ts | 12 + 4 files changed, 1275 insertions(+) create mode 100644 remote/test/puppeteer/test-d/ElementHandle.test-d.ts create mode 100644 remote/test/puppeteer/test-d/JSHandle.test-d.ts create mode 100644 remote/test/puppeteer/test-d/NodeFor.test-d.ts create mode 100644 remote/test/puppeteer/test-d/puppeteer.test-d.ts (limited to 'remote/test/puppeteer/test-d') 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..e23e66678c --- /dev/null +++ b/remote/test/puppeteer/test-d/ElementHandle.test-d.ts @@ -0,0 +1,1024 @@ +import {ElementHandle} from 'puppeteer'; +import {expectNotType, expectType} from 'tsd'; + +declare const handle: ElementHandle; + +{ + { + { + expectType | null>(await handle.$('a')); + expectNotType | null>(await handle.$('a')); + } + { + expectType | null>( + await handle.$('a#id') + ); + expectNotType | null>(await handle.$('a#id')); + } + { + expectType | null>( + await handle.$('a.class') + ); + expectNotType | null>(await handle.$('a.class')); + } + { + expectType | null>( + await handle.$('a[attr=value]') + ); + expectNotType | null>( + await handle.$('a[attr=value]') + ); + } + { + expectType | null>( + await handle.$('a:psuedo-class') + ); + expectNotType | null>( + await handle.$('a:pseudo-class') + ); + } + { + expectType | null>( + await handle.$('a:func(arg)') + ); + expectNotType | null>( + await handle.$('a:func(arg)') + ); + } + } + { + { + expectType | null>(await handle.$('div')); + expectNotType | null>(await handle.$('div')); + } + { + expectType | null>( + await handle.$('div#id') + ); + expectNotType | null>(await handle.$('div#id')); + } + { + expectType | null>( + await handle.$('div.class') + ); + expectNotType | null>(await handle.$('div.class')); + } + { + expectType | null>( + await handle.$('div[attr=value]') + ); + expectNotType | null>( + await handle.$('div[attr=value]') + ); + } + { + expectType | null>( + await handle.$('div:psuedo-class') + ); + expectNotType | null>( + await handle.$('div:pseudo-class') + ); + } + { + expectType | null>( + await handle.$('div:func(arg)') + ); + expectNotType | null>( + await handle.$('div:func(arg)') + ); + } + } + { + { + expectType | null>(await handle.$('some-custom')); + } + { + expectType | null>( + await handle.$('some-custom#id') + ); + } + { + expectType | null>( + await handle.$('some-custom.class') + ); + } + { + expectType | null>( + await handle.$('some-custom[attr=value]') + ); + } + { + expectType | null>( + await handle.$('some-custom:pseudo-class') + ); + } + { + expectType | null>( + await handle.$('some-custom:func(arg)') + ); + } + } + { + { + expectType | null>(await handle.$('')); + } + { + expectType | null>(await handle.$('#id')); + } + { + expectType | null>(await handle.$('.class')); + } + { + expectType | null>(await handle.$('[attr=value]')); + } + { + expectType | null>( + await handle.$(':pseudo-class') + ); + } + { + expectType | null>(await handle.$(':func(arg)')); + } + } + { + { + expectType | null>( + await handle.$('div > a') + ); + expectNotType | null>(await handle.$('div > a')); + } + { + expectType | null>( + await handle.$('div > a#id') + ); + expectNotType | null>( + await handle.$('div > a#id') + ); + } + { + expectType | null>( + await handle.$('div > a.class') + ); + expectNotType | null>( + await handle.$('div > a.class') + ); + } + { + expectType | null>( + await handle.$('div > a[attr=value]') + ); + expectNotType | null>( + await handle.$('div > a[attr=value]') + ); + } + { + expectType | null>( + await handle.$('div > a:psuedo-class') + ); + expectNotType | null>( + await handle.$('div > a:pseudo-class') + ); + } + { + expectType | null>( + await handle.$('div > a:func(arg)') + ); + expectNotType | null>( + await handle.$('div > a:func(arg)') + ); + } + } + { + { + expectType | null>( + await handle.$('div > div') + ); + expectNotType | null>(await handle.$('div > div')); + } + { + expectType | null>( + await handle.$('div > div#id') + ); + expectNotType | null>( + await handle.$('div > div#id') + ); + } + { + expectType | null>( + await handle.$('div > div.class') + ); + expectNotType | null>( + await handle.$('div > div.class') + ); + } + { + expectType | null>( + await handle.$('div > div[attr=value]') + ); + expectNotType | null>( + await handle.$('div > div[attr=value]') + ); + } + { + expectType | null>( + await handle.$('div > div:psuedo-class') + ); + expectNotType | null>( + await handle.$('div > div:pseudo-class') + ); + } + { + expectType | null>( + await handle.$('div > div:func(arg)') + ); + expectNotType | null>( + await handle.$('div > div:func(arg)') + ); + } + } + { + { + expectType | null>( + await handle.$('div > some-custom') + ); + } + { + expectType | null>( + await handle.$('div > some-custom#id') + ); + } + { + expectType | null>( + await handle.$('div > some-custom.class') + ); + } + { + expectType | null>( + await handle.$('div > some-custom[attr=value]') + ); + } + { + expectType | null>( + await handle.$('div > some-custom:pseudo-class') + ); + } + { + expectType | null>( + await handle.$('div > some-custom:func(arg)') + ); + } + } + { + { + expectType | null>(await handle.$('div > #id')); + } + { + expectType | null>(await handle.$('div > .class')); + } + { + expectType | null>( + await handle.$('div > [attr=value]') + ); + } + { + expectType | null>( + await handle.$('div > :pseudo-class') + ); + } + { + expectType | null>( + await handle.$('div > :func(arg)') + ); + } + } + { + { + expectType | null>( + await handle.$('div > a') + ); + expectNotType | null>(await handle.$('div > a')); + } + { + expectType | null>( + await handle.$('div > a#id') + ); + expectNotType | null>( + await handle.$('div > a#id') + ); + } + { + expectType | null>( + await handle.$('div > a.class') + ); + expectNotType | null>( + await handle.$('div > a.class') + ); + } + { + expectType | null>( + await handle.$('div > a[attr=value]') + ); + expectNotType | null>( + await handle.$('div > a[attr=value]') + ); + } + { + expectType | null>( + await handle.$('div > a:psuedo-class') + ); + expectNotType | null>( + await handle.$('div > a:pseudo-class') + ); + } + { + expectType | null>( + await handle.$('div > a:func(arg)') + ); + expectNotType | null>( + await handle.$('div > a:func(arg)') + ); + } + } + { + { + expectType | null>( + await handle.$('div > div') + ); + expectNotType | null>(await handle.$('div > div')); + } + { + expectType | null>( + await handle.$('div > div#id') + ); + expectNotType | null>( + await handle.$('div > div#id') + ); + } + { + expectType | null>( + await handle.$('div > div.class') + ); + expectNotType | null>( + await handle.$('div > div.class') + ); + } + { + expectType | null>( + await handle.$('div > div[attr=value]') + ); + expectNotType | null>( + await handle.$('div > div[attr=value]') + ); + } + { + expectType | null>( + await handle.$('div > div:psuedo-class') + ); + expectNotType | null>( + await handle.$('div > div:pseudo-class') + ); + } + { + expectType | null>( + await handle.$('div > div:func(arg)') + ); + expectNotType | null>( + await handle.$('div > div:func(arg)') + ); + } + } + { + { + expectType | null>( + await handle.$('div > some-custom') + ); + } + { + expectType | null>( + await handle.$('div > some-custom#id') + ); + } + { + expectType | null>( + await handle.$('div > some-custom.class') + ); + } + { + expectType | null>( + await handle.$('div > some-custom[attr=value]') + ); + } + { + expectType | null>( + await handle.$('div > some-custom:pseudo-class') + ); + } + { + expectType | null>( + await handle.$('div > some-custom:func(arg)') + ); + } + } + { + { + expectType | null>(await handle.$('div > #id')); + } + { + expectType | null>(await handle.$('div > .class')); + } + { + expectType | null>( + await handle.$('div > [attr=value]') + ); + } + { + expectType | null>( + await handle.$('div > :pseudo-class') + ); + } + { + expectType | null>( + await handle.$('div > :func(arg)') + ); + } + } +} + +{ + { + { + expectType>>(await handle.$$('a')); + expectNotType>>(await handle.$$('a')); + } + { + expectType>>( + await handle.$$('a#id') + ); + expectNotType>>(await handle.$$('a#id')); + } + { + expectType>>( + await handle.$$('a.class') + ); + expectNotType>>(await handle.$$('a.class')); + } + { + expectType>>( + await handle.$$('a[attr=value]') + ); + expectNotType>>( + await handle.$$('a[attr=value]') + ); + } + { + expectType>>( + await handle.$$('a:psuedo-class') + ); + expectNotType>>( + await handle.$$('a:pseudo-class') + ); + } + { + expectType>>( + await handle.$$('a:func(arg)') + ); + expectNotType>>( + await handle.$$('a:func(arg)') + ); + } + } + { + { + expectType>>(await handle.$$('div')); + expectNotType>>(await handle.$$('div')); + } + { + expectType>>( + await handle.$$('div#id') + ); + expectNotType>>(await handle.$$('div#id')); + } + { + expectType>>( + await handle.$$('div.class') + ); + expectNotType>>( + await handle.$$('div.class') + ); + } + { + expectType>>( + await handle.$$('div[attr=value]') + ); + expectNotType>>( + await handle.$$('div[attr=value]') + ); + } + { + expectType>>( + await handle.$$('div:psuedo-class') + ); + expectNotType>>( + await handle.$$('div:pseudo-class') + ); + } + { + expectType>>( + await handle.$$('div:func(arg)') + ); + expectNotType>>( + await handle.$$('div:func(arg)') + ); + } + } + { + { + expectType>>(await handle.$$('some-custom')); + } + { + expectType>>( + await handle.$$('some-custom#id') + ); + } + { + expectType>>( + await handle.$$('some-custom.class') + ); + } + { + expectType>>( + await handle.$$('some-custom[attr=value]') + ); + } + { + expectType>>( + await handle.$$('some-custom:pseudo-class') + ); + } + { + expectType>>( + await handle.$$('some-custom:func(arg)') + ); + } + } + { + { + expectType>>(await handle.$$('')); + } + { + expectType>>(await handle.$$('#id')); + } + { + expectType>>(await handle.$$('.class')); + } + { + expectType>>( + await handle.$$('[attr=value]') + ); + } + { + expectType>>( + await handle.$$(':pseudo-class') + ); + } + { + expectType>>(await handle.$$(':func(arg)')); + } + } + { + { + expectType>>( + await handle.$$('div > a') + ); + expectNotType>>(await handle.$$('div > a')); + } + { + expectType>>( + await handle.$$('div > a#id') + ); + expectNotType>>( + await handle.$$('div > a#id') + ); + } + { + expectType>>( + await handle.$$('div > a.class') + ); + expectNotType>>( + await handle.$$('div > a.class') + ); + } + { + expectType>>( + await handle.$$('div > a[attr=value]') + ); + expectNotType>>( + await handle.$$('div > a[attr=value]') + ); + } + { + expectType>>( + await handle.$$('div > a:psuedo-class') + ); + expectNotType>>( + await handle.$$('div > a:pseudo-class') + ); + } + { + expectType>>( + await handle.$$('div > a:func(arg)') + ); + expectNotType>>( + await handle.$$('div > a:func(arg)') + ); + } + } + { + { + expectType>>( + await handle.$$('div > div') + ); + expectNotType>>( + await handle.$$('div > div') + ); + } + { + expectType>>( + await handle.$$('div > div#id') + ); + expectNotType>>( + await handle.$$('div > div#id') + ); + } + { + expectType>>( + await handle.$$('div > div.class') + ); + expectNotType>>( + await handle.$$('div > div.class') + ); + } + { + expectType>>( + await handle.$$('div > div[attr=value]') + ); + expectNotType>>( + await handle.$$('div > div[attr=value]') + ); + } + { + expectType>>( + await handle.$$('div > div:psuedo-class') + ); + expectNotType>>( + await handle.$$('div > div:pseudo-class') + ); + } + { + expectType>>( + await handle.$$('div > div:func(arg)') + ); + expectNotType>>( + await handle.$$('div > div:func(arg)') + ); + } + } + { + { + expectType>>( + await handle.$$('div > some-custom') + ); + } + { + expectType>>( + await handle.$$('div > some-custom#id') + ); + } + { + expectType>>( + await handle.$$('div > some-custom.class') + ); + } + { + expectType>>( + await handle.$$('div > some-custom[attr=value]') + ); + } + { + expectType>>( + await handle.$$('div > some-custom:pseudo-class') + ); + } + { + expectType>>( + await handle.$$('div > some-custom:func(arg)') + ); + } + } + { + { + expectType>>(await handle.$$('div > #id')); + } + { + expectType>>( + await handle.$$('div > .class') + ); + } + { + expectType>>( + await handle.$$('div > [attr=value]') + ); + } + { + expectType>>( + await handle.$$('div > :pseudo-class') + ); + } + { + expectType>>( + await handle.$$('div > :func(arg)') + ); + } + } + { + { + expectType>>( + await handle.$$('div > a') + ); + expectNotType>>(await handle.$$('div > a')); + } + { + expectType>>( + await handle.$$('div > a#id') + ); + expectNotType>>( + await handle.$$('div > a#id') + ); + } + { + expectType>>( + await handle.$$('div > a.class') + ); + expectNotType>>( + await handle.$$('div > a.class') + ); + } + { + expectType>>( + await handle.$$('div > a[attr=value]') + ); + expectNotType>>( + await handle.$$('div > a[attr=value]') + ); + } + { + expectType>>( + await handle.$$('div > a:psuedo-class') + ); + expectNotType>>( + await handle.$$('div > a:pseudo-class') + ); + } + { + expectType>>( + await handle.$$('div > a:func(arg)') + ); + expectNotType>>( + await handle.$$('div > a:func(arg)') + ); + } + } + { + { + expectType>>( + await handle.$$('div > div') + ); + expectNotType>>( + await handle.$$('div > div') + ); + } + { + expectType>>( + await handle.$$('div > div#id') + ); + expectNotType>>( + await handle.$$('div > div#id') + ); + } + { + expectType>>( + await handle.$$('div > div.class') + ); + expectNotType>>( + await handle.$$('div > div.class') + ); + } + { + expectType>>( + await handle.$$('div > div[attr=value]') + ); + expectNotType>>( + await handle.$$('div > div[attr=value]') + ); + } + { + expectType>>( + await handle.$$('div > div:psuedo-class') + ); + expectNotType>>( + await handle.$$('div > div:pseudo-class') + ); + } + { + expectType>>( + await handle.$$('div > div:func(arg)') + ); + expectNotType>>( + await handle.$$('div > div:func(arg)') + ); + } + } + { + { + expectType>>( + await handle.$$('div > some-custom') + ); + } + { + expectType>>( + await handle.$$('div > some-custom#id') + ); + } + { + expectType>>( + await handle.$$('div > some-custom.class') + ); + } + { + expectType>>( + await handle.$$('div > some-custom[attr=value]') + ); + } + { + expectType>>( + await handle.$$('div > some-custom:pseudo-class') + ); + } + { + expectType>>( + await handle.$$('div > some-custom:func(arg)') + ); + } + } + { + { + expectType>>(await handle.$$('div > #id')); + } + { + expectType>>( + await handle.$$('div > .class') + ); + } + { + expectType>>( + await handle.$$('div > [attr=value]') + ); + } + { + expectType>>( + await handle.$$('div > :pseudo-class') + ); + } + { + expectType>>( + await handle.$$('div > :func(arg)') + ); + } + } +} + +{ + expectType( + await handle.$eval( + 'a', + (element, int) => { + expectType(element); + expectType(int); + }, + 1 + ) + ); + expectType( + await handle.$eval( + 'div', + (element, int, str) => { + expectType(element); + expectType(int); + expectType(str); + }, + 1, + '' + ) + ); + expectType( + await handle.$eval( + 'a', + (element, value) => { + expectType(element); + return value; + }, + 1 + ) + ); + expectType( + await handle.$eval( + 'some-element', + (element, value) => { + expectType(element); + return value; + }, + 1 + ) + ); + expectType( + await handle.$eval('a', element => { + return element; + }) + ); + expectType(await handle.$eval('a', 'document')); +} + +{ + expectType( + await handle.$$eval( + 'a', + (elements, int) => { + expectType(elements); + expectType(int); + }, + 1 + ) + ); + expectType( + await handle.$$eval( + 'div', + (elements, int, str) => { + expectType(elements); + expectType(int); + expectType(str); + }, + 1, + '' + ) + ); + expectType( + await handle.$$eval( + 'a', + (elements, value) => { + expectType(elements); + return value; + }, + 1 + ) + ); + expectType( + await handle.$$eval( + 'some-element', + (elements, value) => { + expectType(elements); + return value; + }, + 1 + ) + ); + expectType( + await handle.$$eval('a', elements => { + return elements; + }) + ); + expectType(await handle.$$eval('a', 'document')); +} + +{ + { + expectType | null>( + await handle.waitForSelector('a') + ); + expectNotType | null>( + await handle.waitForSelector('a') + ); + } + { + expectType | null>( + await handle.waitForSelector('div') + ); + expectNotType | null>( + await handle.waitForSelector('div') + ); + } + { + expectType | 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..0e1b6385d8 --- /dev/null +++ b/remote/test/puppeteer/test-d/JSHandle.test-d.ts @@ -0,0 +1,83 @@ +import {ElementHandle, JSHandle} from 'puppeteer'; +import {expectNotAssignable, expectNotType, expectType} from 'tsd'; + +declare const handle: JSHandle; + +{ + expectType(await handle.evaluate('document')); + expectType( + await handle.evaluate(() => { + return 1; + }) + ); + expectType( + await handle.evaluate(() => { + return document.body; + }) + ); + expectType( + await handle.evaluate(() => { + return ''; + }) + ); + expectType( + await handle.evaluate((value, str) => { + expectNotAssignable(value); + expectType(str); + return ''; + }, '') + ); +} + +{ + expectType(await handle.evaluateHandle('document')); + expectType>( + await handle.evaluateHandle(() => { + return 1; + }) + ); + expectType>( + await handle.evaluateHandle(() => { + return ''; + }) + ); + expectType>( + await handle.evaluateHandle((value, str) => { + expectNotAssignable(value); + expectType(str); + return ''; + }, '') + ); + expectType>( + await handle.evaluateHandle(() => { + return document.body; + }) + ); +} + +declare const handle2: JSHandle<{test: number}>; + +{ + { + expectType>(await handle2.getProperty('test')); + expectNotType>(await handle2.getProperty('test')); + } + { + expectType>( + await handle2.getProperty('key-doesnt-exist') + ); + expectNotType>( + await handle2.getProperty('key-doesnt-exist') + ); + expectNotType>( + await handle2.getProperty('key-doesnt-exist') + ); + } +} + +{ + void handle.evaluate((value, other) => { + expectType(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..a478b5952c --- /dev/null +++ b/remote/test/puppeteer/test-d/NodeFor.test-d.ts @@ -0,0 +1,156 @@ +import type {NodeFor} from 'puppeteer'; +import {expectType, expectNotType} from 'tsd'; + +declare const nodeFor: ( + selector: Selector +) => NodeFor; + +{ + { + expectType( + 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( + 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(nodeFor('a')); + expectNotType(nodeFor('a')); + } + { + expectType(nodeFor('a#ignored')); + expectNotType(nodeFor('a#ignored')); + } + { + expectType(nodeFor('a.ignored')); + expectNotType(nodeFor('a.ignored')); + } + { + expectType(nodeFor('a[ignored')); + expectNotType(nodeFor('a[ignored')); + } + { + expectType(nodeFor('a:ignored')); + expectNotType(nodeFor('a:ignored')); + } + { + expectType(nodeFor('ignored a')); + expectNotType(nodeFor('ignored a')); + } + { + expectType(nodeFor('ignored a#ignored')); + expectNotType(nodeFor('ignored a#ignored')); + } + { + expectType(nodeFor('ignored a.ignored')); + expectNotType(nodeFor('ignored a.ignored')); + } + { + expectType(nodeFor('ignored a[ignored')); + expectNotType(nodeFor('ignored a[ignored')); + } + { + expectType(nodeFor('ignored a:ignored')); + expectNotType(nodeFor('ignored a:ignored')); + } + { + expectType(nodeFor('ignored > a')); + expectNotType(nodeFor('ignored > a')); + } + { + expectType(nodeFor('ignored > a#ignored')); + expectNotType(nodeFor('ignored > a#ignored')); + } + { + expectType(nodeFor('ignored > a.ignored')); + expectNotType(nodeFor('ignored > a.ignored')); + } + { + expectType(nodeFor('ignored > a[ignored')); + expectNotType(nodeFor('ignored > a[ignored')); + } + { + expectType(nodeFor('ignored > a:ignored')); + expectNotType(nodeFor('ignored > a:ignored')); + } + { + expectType(nodeFor('ignored + a')); + expectNotType(nodeFor('ignored + a')); + } + { + expectType(nodeFor('ignored ~ a')); + expectNotType(nodeFor('ignored ~ a')); + } + { + expectType(nodeFor('ignored | a')); + expectNotType(nodeFor('ignored | a')); + } + { + expectType( + nodeFor('ignored ignored > ignored + ignored | a#ignore') + ); + expectNotType( + nodeFor('ignored ignored > ignored + ignored | a#ignore') + ); + } +} +{ + { + expectType(nodeFor('')); + } + { + expectType(nodeFor('#ignored')); + } + { + expectType(nodeFor('.ignored')); + } + { + expectType(nodeFor('[ignored')); + } + { + expectType(nodeFor(':ignored')); + } + { + expectType(nodeFor('ignored #ignored')); + } + { + expectType(nodeFor('ignored .ignored')); + } + { + expectType(nodeFor('ignored [ignored')); + } + { + expectType(nodeFor('ignored :ignored')); + } + { + expectType(nodeFor('ignored > #ignored')); + } + { + expectType(nodeFor('ignored > .ignored')); + } + { + expectType(nodeFor('ignored > [ignored')); + } + { + expectType(nodeFor('ignored > :ignored')); + } + { + expectType(nodeFor('ignored + #ignored')); + } + { + expectType(nodeFor('ignored ~ #ignored')); + } + { + expectType(nodeFor('ignored | #ignored')); + } + { + expectType( + 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..11128f15f7 --- /dev/null +++ b/remote/test/puppeteer/test-d/puppeteer.test-d.ts @@ -0,0 +1,12 @@ +import puppeteer, { + connect, + defaultArgs, + executablePath, + launch, +} from 'puppeteer'; +import {expectType} from 'tsd'; + +expectType(puppeteer.launch); +expectType(puppeteer.connect); +expectType(puppeteer.defaultArgs); +expectType(puppeteer.executablePath); -- cgit v1.2.3