This repo demonstrates a TypeScript build error caused by importing the internal Lighthouse config:
import mobileConfig from 'lighthouse/core/config/lr-mobile-config.js'When you run tsc, TypeScript throws the following error:
node_modules/lighthouse/core/config/lr-mobile-config.d.ts:8:23 - error TS2503: Cannot find namespace 'LH'.
8 declare const config: LH.Config;Clone the repo:
git clone https://github.com/your-username/lighthouse-ts-error.git
cd lighthouse-ts-errorInstall dependencies:
npm installRun the build:
npm run buildYou should see the TS2503 error coming from lr-mobile-config.d.ts.
The file lighthouse/core/config/lr-mobile-config.d.ts contains:
declare const config: LH.Config;…but LH is not declared in the file, nor is the global type included via:
/// <reference types="lighthouse/types/global-lh" />This breaks TypeScript builds unless you:
- Add that reference manually, or
- Set skipLibCheck: true, or
- Avoid importing internal Lighthouse files