From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.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..c978c81187 --- /dev/null +++ b/remote/test/puppeteer/test-d/JSHandle.test-d.ts @@ -0,0 +1,84 @@ +import {expectNotAssignable, expectNotType, expectType} from 'tsd'; +import {ElementHandle} from '../lib/esm/puppeteer/common/ElementHandle.js'; +import {JSHandle} from '../lib/esm/puppeteer/common/JSHandle.js'; + +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') + ); + } +} + +{ + handle.evaluate((value, other) => { + expectType(value); + expectType<{test: number}>(other); + }, handle2); +} -- cgit v1.2.3