Puppeteer-extra: can't use page.solveRecaptchas() or any other puppeteer-extra functions with TypeScript. Should we document this?

Created on 13 Dec 2020  路  5Comments  路  Source: berstend/puppeteer-extra

Hi,

If you can't use any puppeteer-extra-specific function (e.g. page.solveRecaptchas), please add the following to your tsconfig.json:

    "include": [
        "./node_modules/puppeteer-extra/*.d.ts",
        "./node_modules/puppeteer-extra-*/*.d.ts",
        "./src"
    ]

Your code needs to be located inside ./src. Adding the include property in your tsconfig.json will ignore the existing exclude property.

It will include "ambient" typescript files so that the TypeScript compiler (and langage server) can resolve puppeteer-extra types.

I am not sure why I had to do this.
Here is my whole tsconfig.json for reference purposes:

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "ES2020",
        "strictFunctionTypes": true,
        "moduleResolution": "node"
    },
    "include": [
        "./node_modules/puppeteer-extra/*.d.ts",
        "./node_modules/puppeteer-extra-*/*.d.ts",
        "./src"
    ]
}

I can create a wiki page if you think that it is appropriate, let me know and I'll resort to my best english skill to create it 馃槂.

bug report needs triage

All 5 comments

@clouedoc Would be nice if you can add a new section to the existing wiki entry regarding fixing issues with the ambient declarations :-)
https://github.com/berstend/puppeteer-extra/wiki/TypeScript-usage

Hi,

The problem came back with the project going multiplayer-mode.
Nowadays, I resort to massive use of // @ts-ignore, mostly because I'm too lazy to find the root cause.

Should I still create a wiki entry for reference purposes ?

I resort to massive use of // @ts-ignore

Hmm, this does sound like there's an underlying issue with your TS config.

If you got the time it'd be nice to document your previous fix in the wiki, just in case anyone else runs into this. :-)

@berstend Added some info on adding to ambient types:

https://github.com/berstend/puppeteer-extra/wiki/TypeScript-usage

@clouedoc

Nowadays, I resort to massive use of // @ts-ignore, mostly because I'm too lazy to find the root cause.

Je t'en prie, non!! 馃檲

@prescience-data thanks!

Je t'en prie, non!! 馃檲

J'ai bien peur 馃檲

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Bobchev picture Bobchev  路  6Comments

mrgodhani picture mrgodhani  路  3Comments

svenadlung picture svenadlung  路  8Comments

AdityaAnand1 picture AdityaAnand1  路  9Comments

moltar picture moltar  路  9Comments