FAQ
URL
What happened?
Audit class and similarly named Audit namespace are both exported from the index:
|
import * as LH from '../types/lh.js'; |
|
export {Audit} from './audits/audit.js'; |
What did you expect?
When import type { Audit } from 'lighthouse' class takes precedence, making it impossible to use the Audit namespace.
What have you tried?
I can deep-import it from types/lh.js, but I'd rather not import from the internal implementation.
Some ideas
You could rename the Audit export to IAudit (NAudit whatever..), but that would probably be a breaking change, since the namespace can be exported like this:
export * from 'lighthouse/types/lh.js'
export as namespace LH
Could export types separately, package.json:
{
"exports": {
"types": "types/lh.js"
}
}
Or mark Audit namespace deprecated over IAudit etc.
Also import/export eslint rule might catch collisions like this.
Or maybe there's a way to make TS prefer the namespace export that I don't know of.
How were you running Lighthouse?
node
Lighthouse Version
13.0.3
Chrome Version
No response
Node Version
No response
OS
No response
Relevant log output
FAQ
URL
What happened?
Auditclass and similarly namedAuditnamespace are both exported from the index:lighthouse/core/index.js
Line 14 in f525c6b
lighthouse/core/index.js
Line 119 in f525c6b
What did you expect?
When
import type { Audit } from 'lighthouse'class takes precedence, making it impossible to use theAuditnamespace.What have you tried?
I can deep-import it from
types/lh.js, but I'd rather not import from the internal implementation.Some ideas
You could rename the Audit export to
IAudit(NAuditwhatever..), but that would probably be a breaking change, since the namespace can be exported like this:Could export types separately,
package.json:{ "exports": { "types": "types/lh.js" } }Or mark
Auditnamespace deprecated overIAuditetc.Also
import/exporteslint rule might catch collisions like this.Or maybe there's a way to make TS prefer the namespace export that I don't know of.
How were you running Lighthouse?
node
Lighthouse Version
13.0.3
Chrome Version
No response
Node Version
No response
OS
No response
Relevant log output