question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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 issue

I 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:closed
  • Created 3 years ago
  • Comments:27 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
berstendcommented, Sep 18, 2021

I think I found a way to support typings for all puppeteer versions out of the box 😍

4reactions
berstendcommented, Feb 15, 2021

@ajanian your dependencies don’t list puppeteer or puppeteer-extra? 🤔

In any case, please read this: https://github.com/berstend/puppeteer-extra/issues/428#issuecomment-778679665

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found