lighthouse
lighthouse copied to clipboard
Missing types for `category.supportedModes` and `node.explanation`
FAQ
- [X] Yes, my issue is not about variability or throttling.
- [X] Yes, my issue is not about a specific accessibility audit (file with axe-core instead).
URL
https://clubmate.fi/about
What happened?
Not a big deal, but type defs for category.supportedModes
and node.explanation
fields seem to be missing. Also for www.theverge.com the node.explanation
is not there (under the label-content-name-mismatch
item). Apparently these are more rare fields.
Is this a mistake in the types or the output?
What did you expect?
Complete typing.
What have you tried?
I saved the output to a .ts
file and added a type, then looked for the red squiglies:
import type Result from 'lighthouse/types/lhr/lhr.js'
const foo: Result = { /* LH output */ }
How were you running Lighthouse?
node
Lighthouse Version
11.5.0
Chrome Version
No response
Node Version
v20.11.0
OS
Mac OS
Relevant log output
No response
The Lighthouse Config
type allows supportedModes
on each category but the Result
type does not. TS is accurately reporting that the field is incorrect.
The explanation
seems like an actual issues since we set it but it's not on the types:
https://github.com/GoogleChrome/lighthouse/blob/main/core/audits/accessibility/axe-audit.js#L79
Okay interesting. Could you elaborate on the Config
a bit? Or point me to docs. I don't fully understand how to use that, or why am I seeing supportedModes
in the results?
If I use Config.Category
:
type CategoryConfig = Record<string, Config.Category>
Then it’s missing other properties like id
and score
.
I can extend the types and it seems to work:
type CategoryConfig = Record<string, Config.Category & Result.Category>
Is this correct usage?
Thanks!
Okay interesting. Could you elaborate on the Config a bit? Or point me to docs. I don't fully understand how to use that, or why am I seeing supportedModes in the results?
Yeah I took a look at the generated results, and looks like we are emitting supportedModes
on the result category even though it's not a part of the type. So I guess we should either remove that from the output or add supportedModes
to the types.
I'd like to have a take on this issue. I believe adding supportedModes
would work better
Feel free to submit a PR @An-Yay
Please do it :) I just patched Lighthouse and forgot about it.
Hey @adamraine,
I can pick the issue if it is still pending!
Feel free to submit a PR @parshva-b
G'day folks, I've raised a PR here for this fix. Please let me know if I've got it wrong. Cheers!