From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- remote/test/puppeteer/test-d/JSHandle.test-d.ts | 84 +++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 remote/test/puppeteer/test-d/JSHandle.test-d.ts (limited to 'remote/test/puppeteer/test-d/JSHandle.test-d.ts') 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(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); +} -- cgit v1.2.3