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): add type checking to remaining top-level audits #5090

Merged
merged 4 commits into from
May 2, 2018

Conversation

brendankenny
Copy link
Member

critical-request-chains, user-timings, and a switch on the input of the requestLantern*() methods to (I think) what was intended.

With the other two PRs, this covers all the top-level audits except preload, which has major changes in the works in #5062

@@ -65,7 +65,7 @@ module.exports = [
},
'user-timings': {
score: 1,
displayValue: '',
displayValue: '0',
Copy link
Member Author

Choose a reason for hiding this comment

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

this is just a result of audit.js stringifying displayValue by checking falsyness

const displayValue = result.displayValue ? `${result.displayValue}` : '';

so 0 was getting converted to '' before explicit stringifying in user-timings.js below

@@ -3,7 +3,7 @@
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/

// @ts-nocheck
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't believe the changes here will conflict with #5062

{url: 'http://insecure.com/image.jpeg', scheme: 'http', domain: 'insecure.com'}, // should be de-duped
{url: 'http://insecure.com/image2.jpeg', scheme: 'http', domain: 'insecure.com'},
{url: 'https://google.com/', scheme: 'https', domain: 'google.com'},
{url: 'https://google.com/', parsedURL: {scheme: 'https', host: 'google.com'}},
Copy link
Member Author

Choose a reason for hiding this comment

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

noisy changes to move off scheme and domain, which were just returning the parsedURL properties anyways

requestLanternFirstCPUIdle(data: LH.Artifacts.MetricComputationData): Promise<Artifacts.LanternMetric>;
requestLanternFirstMeaningfulPaint(data: LH.Artifacts.MetricComputationData): Promise<Artifacts.LanternMetric>;
requestLanternSpeedIndex(data: LH.Artifacts.MetricComputationData): Promise<Artifacts.LanternMetric>;
requestLanternInteractive(data: LH.Artifacts.MetricComputationDataInput): Promise<Artifacts.LanternMetric>;
Copy link
Member Author

@brendankenny brendankenny May 2, 2018

Choose a reason for hiding this comment

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

@patrickhulce I believe this was your intention all along (mostly because it works, and that can't be on accident :). I typed these as MetricComputationData based on their calls within the other metrics where the MetricComputationDataInput -> MetricComputationData transition had already taken place, but they of course work without the extra artifacts. This also makes predictive-perf.js work above.

I had to move the optional simulator to MetricComputationDataInput as a result

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes indeed the metric computation data is the internal one that gets augmented 👍

@@ -314,6 +315,7 @@ declare global {

export interface LanternMetric {
timing: number;
timestamp?: never;
Copy link
Member Author

Choose a reason for hiding this comment

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

copied from #5084

SECURE_SCHEMES.includes(record.protocol) ||
SECURE_DOMAINS.includes(record.domain);
SECURE_DOMAINS.includes(record.parsedURL.host);
Copy link
Member

Choose a reason for hiding this comment

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

you're 100% these two are the same?

Copy link
Member Author

Choose a reason for hiding this comment

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

you're 100% these two are the same?

yeah, both our version of the frontend and current master have domain a getter that returns this._parsedURL.host and scheme is this._parsedURL.scheme. Seems better to do this than duplicate (and in the spirit of "use the stable part of the API")

@@ -292,7 +292,7 @@
},
"user-timings": {
"score": 1,
"displayValue": "",
"displayValue": "0",
Copy link
Member

Choose a reason for hiding this comment

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

this does seem weird. can you avoid printing a 0 to the report plz :)
Might as well change it to "6 measures found"

Copy link
Member Author

Choose a reason for hiding this comment

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

can you avoid printing a 0 to the report plz :)

haha, that was my first instinct, but it seemed like too specific of a change to the audit. Done

@@ -144,6 +144,7 @@ declare global {
tid: number;
ts: number;
dur: number;
ph: 'X'|'M'|'B'|'E'|'I'|'O'|'N'|'R'|'D'|'S'|'F';
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

done

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 % nits

@@ -78,32 +83,32 @@ class UserTimings extends Audit {
ut.startTime = (ut.startTime - tabTrace.navigationStartEvt.ts) / 1000;
if (!ut.isMark) {
ut.endTime = (ut.endTime - tabTrace.navigationStartEvt.ts) / 1000;
ut.duration = ut.endTime - ut.startTime;
ut.duration = ut.duration / 1000;
Copy link
Collaborator

Choose a reason for hiding this comment

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

just style?

Copy link
Member Author

Choose a reason for hiding this comment

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

just style?

yeah, had to set a duration when creating the object, and it seemed silly to set it to 0 only to set it to the actual duration a few lines down..

}
});

return userTimings;
}

/*
* @return {!Array<string>}
* @return {Array<string>}
Copy link
Collaborator

Choose a reason for hiding this comment

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

/** ?

@@ -320,7 +320,7 @@
"url": "http://localhost:10200/dobetterweb/dbw_tester.html",
"startTime": 185603.321221,
"endTime": 185603.961376,
"responseReceivedTime": 185603.89718499998,
"_responseReceivedTime": 185603.89718499998,
Copy link
Collaborator

Choose a reason for hiding this comment

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

viewing these inline is a bit annoying it's the only _ 😆 We don't really want folks to use these though I guess

Copy link
Member Author

Choose a reason for hiding this comment

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

viewing these inline is a bit annoying

yeah, it seems like it really shouldn't be in the audit result anyways

requestLanternFirstCPUIdle(data: LH.Artifacts.MetricComputationData): Promise<Artifacts.LanternMetric>;
requestLanternFirstMeaningfulPaint(data: LH.Artifacts.MetricComputationData): Promise<Artifacts.LanternMetric>;
requestLanternSpeedIndex(data: LH.Artifacts.MetricComputationData): Promise<Artifacts.LanternMetric>;
requestLanternInteractive(data: LH.Artifacts.MetricComputationDataInput): Promise<Artifacts.LanternMetric>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

yes indeed the metric computation data is the internal one that gets augmented 👍

@brendankenny brendankenny merged commit 26807e8 into master May 2, 2018
@brendankenny brendankenny deleted the tsaudits3 branch May 2, 2018 21:23
kdzwinel pushed a commit to kdzwinel/lighthouse that referenced this pull request Aug 16, 2018
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.

3 participants