Skip to content

refactor(plugin-google-gtag, plugin-google-analytics): migrate packages to TS#5561

Merged
slorber merged 3 commits intofacebook:mainfrom
Josh-Cena:ganalytics-ts
Sep 22, 2021
Merged

refactor(plugin-google-gtag, plugin-google-analytics): migrate packages to TS#5561
slorber merged 3 commits intofacebook:mainfrom
Josh-Cena:ganalytics-ts

Conversation

@Josh-Cena
Copy link
Collaborator

Motivation

More migration, also provided typings to their ThemeConfig fields.

Hopefully this makes refactoring the themeConfig options to plugin options more convenient

Have you read the Contributing Guidelines on pull requests?

Yes

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Sep 13, 2021
@netlify
Copy link

netlify bot commented Sep 13, 2021

✔️ [V2]
Built without sensitive environment variables

🔨 Explore the source changes: 9417845

🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/61453e445d60ed000765ecf4

😎 Browse the preview: https://deploy-preview-5561--docusaurus-2.netlify.app

@github-actions
Copy link

github-actions bot commented Sep 13, 2021

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟢 Performance 97
🟢 Accessibility 98
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-5561--docusaurus-2.netlify.app/

return {};
}
return {
const HTMLTags = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't understand, why create new const here, if we can return just object as it was before?

Copy link
Collaborator Author

@Josh-Cena Josh-Cena Sep 17, 2021

Choose a reason for hiding this comment

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

That doesn't work and spits out a giant "Type not assignable" error... My best guess is due to some inference funkiness

FWIW, I'll just use type assertion

@slorber slorber added the pr: maintenance This PR does not produce any behavior differences to end users when upgrading. label Sep 22, 2021
Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

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

LGTM thanks

added some comments but we can merge it


return {
onRouteUpdate({location}) {
onRouteUpdate({location}: {location: Location}) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably create a type for js client modules

gtag?: unknown; // TODO type plugin
};
export type ThemeConfig = import('@docusaurus/theme-common').ThemeConfig &
import('@docusaurus/plugin-google-analytics').ThemeConfig &
Copy link
Collaborator

Choose a reason for hiding this comment

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

even for refactored TS packages, we still want to move those themeConfig to options. This feels overly complex to have to provide plugin in plugin array + config in theme config: configuring things in one place would provide better DX

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We will move them to options in the future, this is just temporary

@slorber slorber merged commit 19b27ef into facebook:main Sep 22, 2021
@Josh-Cena Josh-Cena deleted the ganalytics-ts branch September 22, 2021 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA pr: maintenance This PR does not produce any behavior differences to end users when upgrading.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants