-
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
i18n: use IcuMessage objects instead of string IDs #10630
Changes from all commits
30c5ec2
4e614f0
6863549
5c297f8
4455f24
28d0e41
9898a9f
f377a81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -270,7 +270,7 @@ class RenderBlockingResources extends Audit { | |
static async audit(artifacts, context) { | ||
const {results, wastedMs} = await RenderBlockingResources.computeResults(artifacts, context); | ||
|
||
let displayValue = ''; | ||
let displayValue; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these are inferred correctly, right? in tsc playground it seems to work out out OK but some of the assertions we're removing later on in jsdoc makes me think some of them were necessary at one point in time for our checkJs setup... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
yes, they haven't been necessary for a while. I don't remember when conditional initialization like this was added, but basically the CFG typing keeps getting better. |
||
if (results.length > 0) { | ||
displayValue = str_(i18n.UIStrings.displayValueMsSavings, {wastedMs}); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ class ImageAspectRatio extends Audit { | |
|
||
/** | ||
* @param {WellDefinedImage} image | ||
* @return {Error|{url: string, displayedAspectRatio: string, actualAspectRatio: string, doRatiosMatch: boolean}} | ||
* @return {LH.IcuMessage|{url: string, displayedAspectRatio: string, actualAspectRatio: string, doRatiosMatch: boolean}} | ||
*/ | ||
static computeAspectRatios(image) { | ||
const url = URL.elideDataURI(image.src); | ||
|
@@ -68,7 +68,7 @@ class ImageAspectRatio extends Audit { | |
|
||
if (!Number.isFinite(actualAspectRatio) || | ||
!Number.isFinite(displayedAspectRatio)) { | ||
return new Error(str_(UIStrings.warningCompute, {url})); | ||
return str_(UIStrings.warningCompute, {url}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we never use this as an |
||
} | ||
|
||
return { | ||
|
@@ -88,7 +88,7 @@ class ImageAspectRatio extends Audit { | |
static audit(artifacts) { | ||
const images = artifacts.ImageElements; | ||
|
||
/** @type {string[]} */ | ||
/** @type {LH.IcuMessage[]} */ | ||
const warnings = []; | ||
/** @type {Array<{url: string, displayedAspectRatio: string, actualAspectRatio: string, doRatiosMatch: boolean}>} */ | ||
const results = []; | ||
|
@@ -109,8 +109,8 @@ class ImageAspectRatio extends Audit { | |
}).forEach(image => { | ||
const wellDefinedImage = /** @type {WellDefinedImage} */ (image); | ||
const processed = ImageAspectRatio.computeAspectRatios(wellDefinedImage); | ||
if (processed instanceof Error) { | ||
warnings.push(processed.message); | ||
if (i18n.isIcuMessage(processed)) { | ||
warnings.push(processed); | ||
return; | ||
} | ||
|
||
|
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.
wasn't worth pretending this was a
LighthouseError
since either it's a regularError
or we construct it as just an object down on line 224 :)