Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core(tsc): type check config files #5858

Merged
merged 1 commit into from
Aug 20, 2018
Merged

core(tsc): type check config files #5858

merged 1 commit into from
Aug 20, 2018

Conversation

brendankenny
Copy link
Member

This was flagged testing the typescript nightly against the current code base. LH.Config.Category.description and LH.Config.Group.description should both be optional as they are in the LHR, and LH.Config.Category.manualDescription should also exist.

Also adds type annotations to the files themselves so that they're checked directly, rather than indirectly through their use in config.js.

@@ -19,6 +20,7 @@ module.exports = {
audits: [
'byte-efficiency/unused-javascript',
],
// @ts-ignore TODO(bckenny): type extended Config where e.g. category.title isn't required
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a config is extending another one, there's no reason for it to have anything in particular defined, so maybe these could be RecursivePartial<LH.Config.Json>, but we don't want to apply that to e.g. defaultConfig. So we'll have to figure out a good way to conditionally apply it another day.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we have to split the full config typedef from the valid config typedef?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we have to split the full config typedef from the valid config typedef?

yeah, that seems like that might be the only decent way to do it without making the full config typedef useless

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -19,6 +20,7 @@ module.exports = {
audits: [
'byte-efficiency/unused-javascript',
],
// @ts-ignore TODO(bckenny): type extended Config where e.g. category.title isn't required
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we have to split the full config typedef from the valid config typedef?

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.

2 participants