-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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: extract independent LHR types #12914
Conversation
if (!filename.endsWith('util.js')) throw new Error(`Unexpected message: ${icuMessageId}`); | ||
|
||
const key = /** @type {keyof LH.I18NRendererStrings} */ (varName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code doesn't actually verify that's what these strings are (it's just looking for any i18n strings starting with 'report/'
), and there's really no reason for lighthouse-core/
to keep track of that anyways. It is verified in a report test, so we just move the type cast over there (reuse an existing one, actually) so that the report Util.i18n.strings.*
usages are still type checked
@@ -67,7 +67,7 @@ | |||
"dogfood-lhci": "./lighthouse-core/scripts/dogfood-lhci.sh", | |||
"timing-trace": "node lighthouse-core/scripts/generate-timing-trace.js", | |||
"changelog": "conventional-changelog --config ./build/changelog-generator/index.js --infile changelog.md --same-file", | |||
"type-check": "tsc -p . && tsc -p lighthouse-viewer/ && tsc -p lighthouse-treemap/", | |||
"type-check": "tsc -b . && tsc -p lighthouse-viewer/ && tsc -p lighthouse-treemap/", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using -b
/--build
"diagnostics": true | ||
"diagnostics": true, | ||
"composite": true, | ||
"outDir": ".tmp/tsbuildinfo/", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
build mode outputs tsconfig.tsbuildinfo
files so that project references can be faster and re-use already built projects (if files aren't newer than the tsbuildinfo file). We're still not emitting, but it uses this path for the tsbuildinfo files so they're not in the way. It's ok if .tmp
is deleted at any time, it'll just recreate them on the next build
}, | ||
"include": [ | ||
"root.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all the files added here were already in the compile through transitive import
/require
references, composite
projects are just required to have all included files to actually be declared in include
or files
@@ -31,23 +35,6 @@ declare module Audit { | |||
median: number; | |||
} | |||
|
|||
interface ScoreDisplayModes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these were moved to a new audit-result.d.ts
file
@@ -148,97 +146,6 @@ declare global { | |||
} | |||
} | |||
|
|||
/** Simulation settings that control the amount of network & cpu throttling in the run. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to new settings.d.ts
file
/** The unit of `numericValue`, used when the consumer wishes to convert numericValue to a display string. */ | ||
numericUnit?: string; | ||
/** Extra information about the page provided by some types of audits, in one of several possible forms that can be rendered in the HTML report. */ | ||
details?: FormattedIcu<AuditDetails>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely a wart, removing the IcuMessage
from the AuditDetails
types. The LHR shouldn't know anything about IcuMessage
, because there aren't any by the time it's an LHR.
I haven't found a way to cleanly define AuditDetails
without the IcuMessage
s as part of the LHR and then add them for internal usage (kind of like AuditProduct
vs AuditResult
) without needing a ton of subsequent changes, though.
Something to definitely fix before thinking about publishing any types, at least :)
Co-authored-by: Connor Clark <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sweet!
artifacts.d.ts
andgatherer.d.ts
, etctypes/lhr/*.d.ts
a project reference to the rest of the code. The rest of lighthouse can still reference those files normally, but it's kind of an opaque barrier, similar to referencing a library in a node module. Code inside oftypes/lhr/
, however, mostly can't reference code outside (mostly, but close enough for us), which means it should be easy to keep the LHR types standaloneSettings
have moved totypes/lhr/settings.d.ts
and then referenced fromconfig.d.ts
.There's a few moving pieces here, so I can try to split up if that's easier to review. This PR at least shows the point of the moves.
Next: the report/viewer/treemap can build on just the LHR and not the entirety of
lighthouse-core/
, making the report considerably simpler to deal with on its own.