I cannot pass `env.MYBROWSER` as an argument to `puppeteer.launch`.

I have a question regarding TypeScript and trying to use puppeteer. I am encountering a type error. In the following sample code, I cannot pass
env.MYBROWSER
as an argument to
puppeteer.launch
.
import puppeteer from "@cloudflare/puppeteer";

interface Env {
    MYBROWSER: Fetcher;
}

export default {
    async fetch(request: Request, env: Env): Promise<Response> {
        const browser = await puppeteer.launch(env.MYBROWSER);
        const page = await browser.newPage();
        await page.goto("https://example.com");
        const metrics = await page.metrics();
        await browser.close();
        return Response.json(metrics);
    },
};

The error message for the argument is as follows:
The argument of type '{ fetch(input: RequestInfo<unknown, CfProperties<unknown>>, init?: RequestInit<CfProperties<unknown>> | undefined): Promise<Response>; connect(address: string | SocketAddress, options?: SocketOptions | undefined): Socket; }' cannot be assigned to the parameter of type 'BrowserWorker'.
  The type returned by 'fetch(...)' is not compatible between these types.
    Type 'Promise<Response>' cannot be assigned to type 'Promise<global.Response>'.
      Property 'type' does not exist on type 'Response' but is required in type 'import("path/node_modules/undici-types/fetch").Response'.ts(2345)
fetch.d.ts(191, 12): 'type' is declared here.
(property) Env.MYBROWSER: {
    fetch(input: RequestInfo<unknown, CfProperties<unknown>>, init?: RequestInit<CfProperties<unknown>> | undefined): Promise<Response>;
    connect(address: string | SocketAddress, options?: SocketOptions | undefined): Socket;
}

Is there a solution to this issue?
Was this page helpful?