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