Skip to content

lr-mobile-config.d.ts breaks TS builds: Cannot find namespace 'LH' #16503

@robbiecren07

Description

@robbiecren07

FAQ

URL

https://github.com/robbiecren07/lighthouse-ts-error

What happened?

When importing lighthouse/core/config/lr-mobile-config.js, TypeScript throws:
TS2503: Cannot find namespace 'LH'

The issue is that lr-mobile-config.d.ts references LH.Config, but does not include a reference to the LH types (e.g., /// ).

This makes it impossible to import lr-mobile-config.js in a TypeScript project without manually patching or disabling type checks (skipLibCheck).

Proposed fix: Add this to the top of the .d.ts file:
/// <reference types="lighthouse/types/global-lh" />

Or at least document that users must do this in their own tsconfig.json.

What did you expect?

I expected to be able to import the provided Lighthouse mobile config (lighthouse/core/config/lr-mobile-config.js) in a TypeScript project without TypeScript throwing a type error.

Specifically, I expected the corresponding lr-mobile-config.d.ts file to be valid and self-contained, or to properly reference the required LH namespace, so that tsc could compile without needing extra configuration or manual type patching.

What have you tried?

I verified that the error is coming from lr-mobile-config.d.ts, which references the LH namespace without declaring or importing it. I attempted to resolve the issue by:

Adding /// <reference types="lighthouse/types/global-lh" /> manually in my own tsconfig.json and a custom global.d.ts file.

Setting "skipLibCheck": true in tsconfig.json to bypass the error.

Avoiding the import entirely and inlining the config as a workaround.

These workarounds avoid the error, but the type definition should ideally be self-contained or include the required reference internally.

How were you running Lighthouse?

node

Lighthouse Version

12.6.0

Chrome Version

No response

Node Version

20.17.0

OS

No response

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions