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 fonts gatherer #5018

Merged
merged 2 commits into from
Apr 23, 2018
Merged

core(tsc): add type checking to fonts gatherer #5018

merged 2 commits into from
Apr 23, 2018

Conversation

brendankenny
Copy link
Member

one of the big @ts-nochecked gatherers

[
driver.evaluateAsync(`(${getAllLoadedFonts.toString()})(${args})`),
driver.evaluateAsync(`(${getFontFaceFromStylesheets.toString()})()`),
]
).then(([loadedFonts, fontFaces]) => {
return loadedFonts.map(fontFace => {
if (fontFace.err) {
Copy link
Member Author

Choose a reason for hiding this comment

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

as far as I can tell, this was a bug. fontFace came from getAllLoadedFonts while it was getFontFaceFromStylesheets that generates the error objects it's looking for

stretch: rule.style.fontStretch || 'normal',
style: rule.style.fontStyle || 'normal',
weight: rule.style.fontWeight || 'normal',
variant: rule.style.fontVariant || 'normal',
// @ts-ignore (currently) non-standard Chrome extension to CSSStyleDeclaration
Copy link
Member

Choose a reason for hiding this comment

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

i dont think these are non-standard, they're just fairly new.

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 dont think these are non-standard, they're just fairly new.

apparently (supposedly?) the non-standard part is taking standard @font-face descriptors and putting them as properties on CSSStyleDeclaration.

This is based on discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1296373#c4, which is admittedly 2 years old, but the linked draft specs seem to still back this up

Copy link
Member Author

Choose a reason for hiding this comment

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

adding link to that discussion

}
}
// Flatten results
return Promise.all(promises).then(fontFaces => [].concat(...fontFaces));
return Promise.all(corsDataPromises).then(corsFontFaces => data.concat(...corsFontFaces));
Copy link
Member

Choose a reason for hiding this comment

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

nice clean up separating promises and data!

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.

seems good to me!

@@ -15,6 +15,13 @@ declare global {
code?: string;
}

/** Make properties K in T optional. */
type MakeOptional<T, K extends keyof T> = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this actually get used anywhere? Seems like you might have opted for Exclude instead

Copy link
Member Author

Choose a reason for hiding this comment

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

Does this actually get used anywhere?

yeah, bad split from #5019

@paulirish paulirish merged commit 670a77a into master Apr 23, 2018
@paulirish paulirish deleted the tsfonts branch April 23, 2018 19:00
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.

4 participants