Skip to content

LH Puppeteer union types TypeScript error #14654

@benschwarz

Description

@benschwarz

FAQ

URL

https://no-url.tld

What happened?

While using Lighthouse from #main (9.5.0-dev.20230105 for example), I receive type failures from puppeteer/puppeteerCore union types:

> tsc

node_modules/lighthouse/types/puppeteer.d.ts:16:25 - error TS2503: Cannot find namespace 'puppeteerCore'.

16   export type Browser = puppeteerCore.Browser | puppeteer.Browser;
                           ~~~~~~~~~~~~~

node_modules/lighthouse/types/puppeteer.d.ts:16:49 - error TS2833: Cannot find namespace 'puppeteer'. Did you mean 'Puppeteer'?

16   export type Browser = puppeteerCore.Browser | puppeteer.Browser;
                                                   ~~~~~~~~~

node_modules/lighthouse/types/puppeteer.d.ts:17:22 - error TS2503: Cannot find namespace 'puppeteerCore'.

17   export type Page = puppeteerCore.Page | puppeteer.Page;
                        ~~~~~~~~~~~~~

node_modules/lighthouse/types/puppeteer.d.ts:17:43 - error TS2833: Cannot find namespace 'puppeteer'. Did you mean 'Puppeteer'?

17   export type Page = puppeteerCore.Page | puppeteer.Page;
                                             ~~~~~~~~~

node_modules/lighthouse/types/puppeteer.d.ts:18:28 - error TS2503: Cannot find namespace 'puppeteerCore'.

18   export type CDPSession = puppeteerCore.CDPSession | puppeteer.CDPSession;
                              ~~~~~~~~~~~~~

node_modules/lighthouse/types/puppeteer.d.ts:18:55 - error TS2833: Cannot find namespace 'puppeteer'. Did you mean 'Puppeteer'?

18   export type CDPSession = puppeteerCore.CDPSession | puppeteer.CDPSession;
                                                         ~~~~~~~~~

node_modules/lighthouse/types/puppeteer.d.ts:19:28 - error TS2503: Cannot find namespace 'puppeteerCore'.

19   export type Connection = puppeteerCore.Connection | puppeteer.Connection;
                              ~~~~~~~~~~~~~

node_modules/lighthouse/types/puppeteer.d.ts:19:55 - error TS2833: Cannot find namespace 'puppeteer'. Did you mean 'Puppeteer'?

19   export type Connection = puppeteerCore.Connection | puppeteer.Connection;
                                                         ~~~~~~~~~

Regardless of if I'm using puppeteer, puppeteer core, or have both installed, this failure is present.

+cc @adamraine - I think you were looking at types recently?

What did you expect?

Expected no TypeScript errors

What have you tried?

Using puppeteer, puppeteer core, ensuring all other TS errors are resolved prior.

How were you running Lighthouse?

node

Lighthouse Version

9.5.0-dev.20230105

Chrome Version

108

Node Version

18

OS

Mac

References

tsconfig.json:

{
  "compilerOptions": {
    "allowJs": true,
    "checkJs": true,
    "composite": true,
    "module": "NodeNext",
    "esModuleInterop": true,
    "target": "esnext",
    "noImplicitAny": false,
    "moduleResolution": "Node",
    "sourceMap": true,
    "outDir": "dist",
    "typeRoots": ["./types", "./node_modules/@types"],
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "baseUrl": ".",
    "resolveJsonModule": true,
    "paths": {
      "*": ["./node_modules/*", "./src/types/*"]
    }
  },
  "include": ["src/**/*"]
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions