SamuelScheit / puppeteer-stream

A Library for puppeteer to retrieve audio and/or video streams
MIT License
358 stars 114 forks source link

Better typescript types #34

Closed euberdeveloper closed 2 years ago

euberdeveloper commented 2 years ago

I am facing a problem with Typescript. You should export a type "PuppeteerStreamBrowser" that is returned when there is the launch. Otherwise either it will have to be implicit (so I can not explicitly write it in the code, e.g. in a class field type annotation) or, if the puppeteer's browser type is used, when getting the stream an as any is required, because the puppeteer browser is just a supertype

SamuelScheit commented 2 years ago

PuppeteerStream doesn't add any properties to the puppeteer browser instance, but I'll explicitly define the return type of the launch method 👍

euberdeveloper commented 2 years ago

It is true, but maybe I have a different error

The problem is here: https://github.com/euberdeveloper/bbb-video-scraper/blob/a949a084a8027cf68a9d456e81c22713ea9548cd/source/utils/scraper.ts#L130

If I use the puppeteer types, the method complains that it is missing some methods, probably because the Page you return is modified

Also by returning it again one has not to put puppeteer as dependency to import the type