Skip to content

Conversation

@brendankenny
Copy link
Contributor

follow up to #11752

I did an audit of the other casts I could find and eliminated any that were unnecessary or easy to work around. In the remaining ones, there are some that aren't really casts (typing the initial value of a reduce call), some that are annoyingly necessary (tuples, depending on where they come from/are going), and some ugly ones that are hard to remove but we should get around to fixing at some point.

@brendankenny brendankenny requested a review from a team as a code owner December 2, 2020 23:09
@brendankenny brendankenny requested review from patrickhulce and removed request for a team December 2, 2020 23:09
@google-cla google-cla bot added the cla: yes label Dec 2, 2020
static async computeObservedMetric(data) {
const {traceOfTab} = data;
if (!traceOfTab.timestamps.firstMeaningfulPaint) {
if (traceOfTab.timings.firstMeaningfulPaint === undefined) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

for these, timestamp is allowed to be undefined in the return type, so better to just check timings directly rather than check one and cast the other.

/** @type {[string, LH.Config.AuditDefn]} */
([audit.implementation.meta.id, audit])
));
/** @type {Map<string, LH.Config.AuditDefn>} */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

improved tuple inference

/** @type {Record<number, Set<Node>>} */
this._nodes = {};
this._dns = new DNSCache({rtt: this._rtt});
/** @type {ConnectionPool} */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we're going to @ts-expect-error regardless, might as well not cast :)

return false;
}
const part = /** @type {string} */(parts.pop());
const part = parts[parts.length - 1];
Copy link
Collaborator

Choose a reason for hiding this comment

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

😆 this is a funny one :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I had the same thought :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't say all of these were Platonic monuments to type checking, just that the type casts weren't needed :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants