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

feat(v2): Provide typing to most of the theme-classic components #3348

Merged
merged 2 commits into from
Aug 28, 2020
Merged

feat(v2): Provide typing to most of the theme-classic components #3348

merged 2 commits into from
Aug 28, 2020

Conversation

SamChou19815
Copy link
Contributor

@SamChou19815 SamChou19815 commented Aug 27, 2020

Motivation

This PR adds type definitions for almost all theme classic components. I only left

  • @theme/MDXPage untyped because we need to add types to page plugin first, which can be done in another PR.
  • @theme/NavbarItem/DefaultNavbarItem, @theme/NavbarItem/DocsVersionDropdownNavbarItem, @theme/NavbarItem/DocsVersionNavbarItem and @theme/NavbarItem untyped, because the usage is too dynamic. Maybe I will setup some function overload definition in another PR.

The rest of the changes are mostly moving from existing in-file props definition into the centralized typed.d.ts. In this way, we can test the accuracy of types by their usages in theme-classic and provide them to the end users.

I also make the type definition available in the v2 website package, and now it has nice type hovers:

Screen Shot 2020-08-27 at 13 48 48

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

This PR only contains type changes. Everything still type checks.

Related PRs

(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Aug 27, 2020
@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Aug 27, 2020

Deploy preview for docusaurus-2 ready!

Built with commit 7b346e5

https://deploy-preview-3348--docusaurus-2.netlify.app

@SamChou19815 SamChou19815 marked this pull request as ready for review August 27, 2020 17:56
@slorber
Copy link
Collaborator

slorber commented Aug 28, 2020

Looks nice thanks ;)

@slorber slorber added the pr: new feature This PR adds a new API or behavior. label Aug 28, 2020
@slorber slorber merged commit bd9b661 into facebook:master Aug 28, 2020
@SamChou19815 SamChou19815 deleted the more-theme-typing branch August 28, 2020 10:55
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: new feature This PR adds a new API or behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants