1- import { ElementHandle , EvaluateFn , HTTPRequest , HTTPResponse , Page , WaitForOptions , WaitTimeoutOptions } from 'puppeteer-core' ;
2- import { KeysOfType , Prototype } from '../../../typings/chrome-aws-lambda' ;
1+ import { ElementHandle , EvaluateFunc , HTTPRequest , HTTPResponse , Page , WaitForOptions , WaitTimeoutOptions } from 'puppeteer-core' ;
2+ import { Prototype } from '../../../typings/chrome-aws-lambda' ;
33
44let Super : Prototype < ElementHandle > = null ;
55
66try {
7- Super = require ( 'puppeteer/lib/cjs/puppeteer/common/JSHandle .js' ) . ElementHandle ;
7+ Super = require ( 'puppeteer/lib/cjs/puppeteer/common/ElementHandle .js' ) . ElementHandle ;
88} catch ( error ) {
9- Super = require ( 'puppeteer-core/lib/cjs/puppeteer/common/JSHandle .js' ) . ElementHandle ;
9+ Super = require ( 'puppeteer-core/lib/cjs/puppeteer/common/ElementHandle .js' ) . ElementHandle ;
1010}
1111
1212Super . prototype . clear = function ( ) {
@@ -171,7 +171,7 @@ Super.prototype.fillFormByLabel = function <T extends Record<string, boolean | s
171171 return result ;
172172 } ;
173173
174- return this . evaluate ( callback as unknown as EvaluateFn < Element > , data ) as any ;
174+ return this . evaluate ( callback as unknown as EvaluateFunc < [ ElementHandle < Element > , T ] > , data ) as any ;
175175} ;
176176
177177Super . prototype . fillFormByName = function < T extends Record < string , boolean | string | string [ ] > > ( data : T ) {
@@ -262,7 +262,7 @@ Super.prototype.fillFormByName = function <T extends Record<string, boolean | st
262262 return result ;
263263 } ;
264264
265- return this . evaluate ( callback as unknown as EvaluateFn < Element > , data ) as any ;
265+ return this . evaluate ( callback as unknown as EvaluateFunc < [ ElementHandle < Element > , T ] > , data ) as any ;
266266} ;
267267
268268Super . prototype . fillFormBySelector = function < T extends Record < string , boolean | string | string [ ] > > ( data : T ) {
@@ -353,7 +353,7 @@ Super.prototype.fillFormBySelector = function <T extends Record<string, boolean
353353 return result ;
354354 } ;
355355
356- return this . evaluate ( callback as unknown as EvaluateFn < Element > , data ) as any ;
356+ return this . evaluate ( callback as unknown as EvaluateFunc < [ ElementHandle < Element > , T ] > , data ) as any ;
357357} ;
358358
359359Super . prototype . fillFormByXPath = function < T extends Record < string , boolean | string | string [ ] > > ( data : T ) {
@@ -450,7 +450,7 @@ Super.prototype.fillFormByXPath = function <T extends Record<string, boolean | s
450450 return result ;
451451 } ;
452452
453- return this . evaluate ( callback as unknown as EvaluateFn < Element > , data ) as any ;
453+ return this . evaluate ( callback as unknown as EvaluateFunc < [ ElementHandle < Element > , T ] > , data ) as any ;
454454} ;
455455
456456Super . prototype . getInnerHTML = function ( ) {
@@ -465,8 +465,8 @@ Super.prototype.getInnerText = function () {
465465 } ) ;
466466} ;
467467
468- Super . prototype . number = function < T = HTMLElement > ( decimal : string = '.' , property : KeysOfType < T , string > = 'textContent' as any ) {
469- let callback = ( node : T , decimal : string , property : KeysOfType < T , string > ) => {
468+ Super . prototype . number = function ( decimal : string = '.' , property : any ) {
469+ let callback = ( node : any , decimal : string , property : any ) => {
470470 let data = ( node [ property ] as unknown ) as string ;
471471
472472 if ( typeof data === 'string' ) {
@@ -486,7 +486,7 @@ Super.prototype.number = function <T = HTMLElement>(decimal: string = '.', prope
486486 return null ;
487487 } ;
488488
489- return this . evaluate ( callback as unknown as EvaluateFn < Element > , decimal , property as any ) ;
489+ return this . evaluate ( callback , decimal , property as any ) ;
490490} ;
491491
492492Super . prototype . selectByLabel = function ( ...values : string [ ] ) {
@@ -523,11 +523,11 @@ Super.prototype.selectByLabel = function (...values: string[]) {
523523 return result ;
524524 } ;
525525
526- return this . evaluate ( callback as unknown as EvaluateFn < Element > , values ) ;
526+ return this . evaluate ( callback as any , values ) ;
527527} ;
528528
529- Super . prototype . string = function < T = HTMLElement > ( property : KeysOfType < T , string > = 'textContent' as any ) {
530- let callback = ( node : T , property : KeysOfType < T , string > ) => {
529+ Super . prototype . string = function ( property : any ) {
530+ let callback = ( node : any , property : any ) => {
531531 let data = ( node [ property ] as unknown ) as string ;
532532
533533 if ( typeof data === 'string' ) {
@@ -553,5 +553,5 @@ Super.prototype.string = function <T = HTMLElement>(property: KeysOfType<T, stri
553553 return null ;
554554 } ;
555555
556- return this . evaluate ( callback as unknown as EvaluateFn < Element > , property as any ) ;
556+ return this . evaluate ( callback , property as any ) ;
557557} ;
0 commit comments