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 seo gatherers #4991

Merged
merged 2 commits into from
Apr 19, 2018
Merged

core(tsc): add type checking to seo gatherers #4991

merged 2 commits into from
Apr 19, 2018

Conversation

brendankenny
Copy link
Member

except only some basic fixes in font-size for now, because it really likes mutating types and it calls into WebInspector stuff :P

No functional changes.

return {href, hreflang};
return {
href: href || '',
hreflang: hreflang || '',
Copy link
Member Author

@brendankenny brendankenny Apr 19, 2018

Choose a reason for hiding this comment

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

@kdzwinel the compiler complained that these could be null, not just strings. It is correct wrt getAttribute, and I guess there could be some malformed <link>s in pages? However the audit was expecting only strings here, so I'm not sure if I'm missing something or we just aren't covering that possibility yet

Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like you found a bug (this whole typescript thing might be a good idea after all! 😉) . Hreflang audit is certainly not prepared for hreflang being null (https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/audits/seo/hreflang.js#L34).

Copy link
Member Author

Choose a reason for hiding this comment

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

are you ok with leaving with these defaults for now and you could update to what makes sense when you get the chance? (I assume handle the null case if matching the pattern of the other seo artifacts)

Copy link
Collaborator

@kdzwinel kdzwinel Apr 19, 2018

Choose a reason for hiding this comment

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

are you ok with leaving with these defaults for now

yeah, that SG

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.

this is all so exciting!!! 😃🤓

/**
* @param {!Node} node
* @param {LH.Artifacts.FontSize.DomNodeWithParent} node
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we have any guidance on when to break out into separate interface vs. do it inline and the LH.Artifacts['Artifact'] method?

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'm open to whatever. We could always access by property (even if there's a distinct interface) just to keep it consistent. Or we could always define a distinct interface, even if the type is string|null (really the only downside is excessive file size, but d.ts files always end up huge).

The rule I was following was strictly "can it fit easily on one line" and had no other significant thought put into it :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

gotcha, wfm!

@@ -3,6 +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
Collaborator

Choose a reason for hiding this comment

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

is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah. The file reaches into WebInspector.CSSMatchedStyles and mutates types in filter/map pipelines which always ends up as a lot of work in TS. I got pretty far but eventually gave up, so settled just for param/return types for now :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah ok, sg

.then(content => ({status: response.status, content}));
})
.catch(_ => ({status: null, content: null}));
return response.text().then(content => ({status: response.status, content}));
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we just await this too while we're at it? I think we might have to for the semantics to be the same anyhow

Copy link
Member Author

Choose a reason for hiding this comment

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

whoops, good catch

@brendankenny
Copy link
Member Author

appveyor is refusing to pass, but it's just the byte-efficiency smoke tests (and, to its credit, expected: ">500", found: 480 is a lot closer than it usually gets :)

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.

😎

@paulirish paulirish merged commit d9450d5 into master Apr 19, 2018
@paulirish paulirish deleted the tsseo branch April 19, 2018 19:49
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.

5 participants