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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(v2): migrate to Typescript 鉂勶笍馃寑馃悑 #1490

Merged
merged 6 commits into from
May 18, 2019
Merged

Conversation

endiliey
Copy link
Contributor

@endiliey endiliey commented May 18, 2019

Motivation

Background

Docusaurus currently doesn't have any static typing and this has been a painful point for us the maintainers of this repo. In order to move faster and confidently in the future, we have decided to add static typing to our codebase, in particular for Docusaurus 2 codebase while it is still not mature yet.

We, the Docusaurus core team have privately discussed on whch static typing to choose initially and we came to decide between Flow, ReasonML and Typescript.

Initially we decided to go with Flow (because me and Yangshun is familiar with it) but after trying it, we decided to drop it. The library definition is much less than Typescript and the community is smaller too. It makes much more sense to use TS rather than Flow if what we want is just an addition to JavaScript.
We are also very influenced by other popular OSS project move to TS (Example: jestjs/jest#7554)

However, we also decided to try ReasonML because it has a rock solid type system and it looks very promising. At first, we are quite happy with it but we realize that the learning curve is too steep and the community is even smaller. It's a very risky move to use ReasonML and that will make our external contributors even less. Nobody is working on Docusaurus full-time, so to keep the project alive, we'll have to rely on contributors.

So, we decided to go with Typescript. We believe the complexity of adding static typing is worth it in the long-term. We can write codes more confidently (looking at you, JavaScript :)) and it will be easier for new contributors to understand the codebase.

Changes

So, this PR is the very beginning move of Docusaurus to Typescript. Starting with @docusaurus/utils
I think this is a good start. Will be adding more in the future

Extra changes:

  • Upgrade webpack-dev-server
  • Add yarn start and yarn build command at root to make it easier to start website without having to go to website directory (cd website)

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

  • Locally nothing wrong
  • Netlify should pass

@endiliey endiliey requested a review from yangshun as a code owner May 18, 2019 12:49
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label May 18, 2019
@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented May 18, 2019

Deploy preview for docusaurus-2 ready!

Built with commit 048ab16

https://deploy-preview-1490--docusaurus-2.netlify.com

@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented May 18, 2019

Deploy preview for docusaurus-preview ready!

Built with commit 048ab16

https://deploy-preview-1490--docusaurus-preview.netlify.com

@facebook facebook deleted a comment from docusaurus-bot May 18, 2019
@facebook facebook deleted a comment from docusaurus-bot May 18, 2019
@facebook facebook deleted a comment from docusaurus-bot May 18, 2019
Copy link
Contributor

@yangshun yangshun left a comment

Choose a reason for hiding this comment

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

Thanks so much for adding types! 鈱笍

@@ -2,3 +2,4 @@ dist
node_modules
build
.docusaurus
packages/docusaurus-utils/lib/
Copy link
Contributor

@yangshun yangshun May 18, 2019

Choose a reason for hiding this comment

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

Why do we Prettier ignore this? Will all TS files be Prettier ignored? Are they meant to be?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lib is the compiled file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants