[Bug] Example typescript code doesn't work - Argument of type '{ headless: boolean; }' is not assignable to parameter of type 'LaunchOptions'. Object literal may only specify known properties, and 'headless' does not exist in type 'LaunchOptions'.
See original GitHub issueI am successfully using puppeteer-extra in my typescript project. I wanted to set headless: false in my launch according to the sample code. I looked and something appears wrong with my types. I have stripped the problem down to a trivial sample project.
Sample Code
import puppeteer from 'puppeteer-extra';
import StealthPlugin from 'puppeteer-extra-plugin-stealth';
puppeteer.use(StealthPlugin());
(async (): Promise<void> => {
const browser = await puppeteer.launch({ headless: false });
await browser.close();
})();
Transpile Error
❯ tsc -p .
src/index.ts:7:46 - error TS2345: Argument of type '{ headless: boolean; }' is not assignable to parameter of type 'LaunchOptions'.
Object literal may only specify known properties, and 'headless' does not exist in type 'LaunchOptions'.
7 const browser = await puppeteer.launch({ headless: false });
~~~~~~~~~~~~~~~
Found 1 error.
Versions
❯ npx envinfo@latest --system --binaries --npmPackages '*(puppeteer*|playwright*|automation-extra*|@extra*)'
Need to install the following packages:
envinfo@latest
Ok to proceed? (y)
System:
OS: macOS 11.2
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 54.80 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 15.8.0 - /usr/local/bin/node
npm: 7.5.0 - /usr/local/bin/npm
npmPackages:
puppeteer-extra-plugin-stealth: ^2.7.4 => 2.7.4
Package.json
{
"name": "pex",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Andrew Janian <andrew@janian.net>",
"license": "ISC",
"dependencies": {
"puppeteer-extra-plugin-stealth": "^2.7.4"
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:27 (5 by maintainers)
Top Results From Across the Web
Object literal may only specify known properties, and 'name ...
The problem is that ApexAxisChartSeries is an Array type. So you ether need to change the ApexAxisChartSeries to be an Object or return...
Read more >PyCharm 181.4203.547 Release Notes | Knowledge Base
Feature PY‑20770 Support Python 3.6 asynchronous generators and comprehensions
Feature PY‑21768 Semantic highlighting for Python
Bug PY‑19573 Python console ‑ no output under OS X
Bug...
Read more >Practical Puppeteer: How to evaluate XPath expression
Today I will share about how to evaluate XPath expression in Puppeteer using $x API and in addition we will also use waitForXPath...
Read more >Changelog - Cypress Documentation
Users working in React Component Testing projects can now generate a basic spec file from the components that exist in their project. Addresses...
Read more >types/puppeteer/index.d.ts - UNPKG
* This method runs `document.querySelector` within the context and passes it as the first argument to `pageFunction`. 81, * If there's no element...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think I found a way to support typings for all puppeteer versions out of the box 😍
@ajanian your dependencies don’t list
puppeteer
orpuppeteer-extra
? 🤔In any case, please read this: https://github.com/berstend/puppeteer-extra/issues/428#issuecomment-778679665