Skip to content

core: add public Lighthouse types entrypoint#17028

Merged
connorjclark merged 3 commits into
GoogleChrome:mainfrom
KirtiRamchandani:fix/public-lh-types-entry
Jun 1, 2026
Merged

core: add public Lighthouse types entrypoint#17028
connorjclark merged 3 commits into
GoogleChrome:mainfrom
KirtiRamchandani:fix/public-lh-types-entry

Conversation

@KirtiRamchandani

Copy link
Copy Markdown
Contributor

Problem

core/index.js exports both the Audit class and the LH namespace types from types/lh.js. TypeScript consumers who need the LH.Audit namespace currently have to deep-import lighthouse/types/lh.js, which looks like an implementation path.

Fixes #16923.

Root cause

The package root has a name collision between the runtime Audit class export and the type namespace export. Renaming either export would be breaking, and the existing deep import is not an obvious public API.

Solution

Add a top-level type-only types.js entrypoint that re-exports types/lh.js, include it in the declaration build, and cover the entrypoint in the module test. Consumers can now use import type { Audit } from 'lighthouse/types.js' without relying on the nested implementation path.

Tests

  • corepack yarn type-check
  • corepack yarn build-report --flow --standalone
  • corepack yarn mocha --testMatch core/test/index-test.js
  • corepack yarn eslint core/test/index-test.js types.js --quiet
  • git diff --check
  • Verified generated declaration content for .tmp/tsbuildinfo/types.d.ts
  • Verified a TypeScript API smoke test can import Audit and Flags from the generated root types.d.ts shape

@KirtiRamchandani KirtiRamchandani requested a review from a team as a code owner May 25, 2026 11:57
@KirtiRamchandani KirtiRamchandani requested review from connorjclark and removed request for a team May 25, 2026 11:57
@connorjclark connorjclark reopened this Jun 1, 2026
@connorjclark

Copy link
Copy Markdown
Collaborator

This works great, thanks!

@connorjclark connorjclark merged commit 5fca441 into GoogleChrome:main Jun 1, 2026
30 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Naming collision: Lighthouse exports Audit class and Audit namespace from the root

2 participants