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

fix(module-type-aliases): move @type packages to dependencies #5601

Merged
merged 3 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
"devDependencies": {
"@docusaurus/module-type-aliases": "2.0.0-beta.6",
"@tsconfig/docusaurus": "^1.0.4",
"@types/react": "^17.0.14",
"@types/react-helmet": "^6.1.2",
"@types/react-router-dom": "^5.1.8",
"typescript": "^4.3.5"
},
"browserslist": {
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-module-type-aliases/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"url": "https://github.com/facebook/docusaurus.git",
"directory": "packages/docusaurus-module-type-aliases"
},
"devDependencies": {
"dependencies": {
"@types/react": "*",
"@types/react-helmet": "*",
"@types/react-loadable": "*",
Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@docusaurus/types",
"version": "2.0.0-beta.6",
"description": "Common types for Docusaurus packages.",
"main": "./src/index.js",
"types": "./src/index.d.ts",
"publishConfig": {
"access": "public"
Expand Down
10 changes: 0 additions & 10 deletions packages/docusaurus-types/src/index.js

This file was deleted.

4 changes: 2 additions & 2 deletions website/docs/typescript-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Below are some guides on how to migrate an existing project to TypeScript.

## Setup {#setup}

To start using TypeScript, add `@docusaurus/module-type-aliases` and some `@types` dependencies to your project:
To start using TypeScript, add `@docusaurus/module-type-aliases` and the base TS config to your project:

```bash npm2yarn
npm install --save-dev typescript @docusaurus/module-type-aliases @types/react @types/react-router-dom @types/react-helmet @tsconfig/docusaurus
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 remove those from the TS template as well?

Are you sure it works? I don't think we have any e2e test on this yet

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

dependencies will be installed transitively but devDependencies don't, so afaik it should work. I'll update the template and check it out

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks, let me know if the TS template still works

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Taking longer than I thought🧐 Tried to set up a verdaccio registry locally, but when I npm_config_registry=http://localhost:4873 yarn install, I still get the real 2.0.0-beta.6 version on npm

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@slorber Tested, it's working🎉

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks 👍

FYI I added a readme in init package with simpler local testing instructions without Verdaccio:


@docusaurus/init

Create Docusaurus apps easily.

Usage

Please see the installation documentation.

For maintainers

For Docusaurus maintainers, templates can be tested with:

cd `git rev-parse --show-toplevel` # Back to repo root
rm -rf test-website
yarn docusaurus-init init test-website classic
cd test-website
yarn start

Note: test-website is not part of the workspace and use packages from npm.

Use the following to test the templates against local packages:

cd `git rev-parse --show-toplevel` # Back to repo root
rm -rf test-website-in-workspace
yarn docusaurus-init init test-website-in-workspace classic
cd test-website-in-workspace
yarn start

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Um, the problem here is whether npm installs @types/ dependencies transitively, so I do need to mock that process of running the whole yarn install process

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah I see 😅

npm install --save-dev typescript @docusaurus/module-type-aliases @tsconfig/docusaurus
```

Then add `tsconfig.json` to your project root with the following content:
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4357,7 +4357,7 @@
"@types/webpack" "^4"
"@types/webpack-dev-server" "*"

"@types/react-helmet@*", "@types/react-helmet@^6.0.0", "@types/react-helmet@^6.1.2":
"@types/react-helmet@*", "@types/react-helmet@^6.0.0":
version "6.1.2"
resolved "https://registry.yarnpkg.com/@types/react-helmet/-/react-helmet-6.1.2.tgz#e9d7d16b29e4ec5716711c52c35c3cec45819eac"
integrity sha512-dcfAZNlWb5JYFbO9CGfrPWLJAyFcT6UeR3u35eBbv8liY2Rg4K7fM1G5+HnwVgot+C+kVwXAZ8pLEn2jsMfTDg==
Expand All @@ -4381,7 +4381,7 @@
"@types/react" "*"
"@types/react-router" "*"

"@types/react-router-dom@*", "@types/react-router-dom@^5.1.8":
"@types/react-router-dom@*":
version "5.1.8"
resolved "https://registry.yarnpkg.com/@types/react-router-dom/-/react-router-dom-5.1.8.tgz#bf3e1c8149b3d62eaa206d58599de82df0241192"
integrity sha512-03xHyncBzG0PmDmf8pf3rehtjY0NpUj7TIN46FrT5n1ZWHPZvXz32gUyNboJ+xsL8cpg8bQVLcllptcQHvocrw==
Expand All @@ -4398,7 +4398,7 @@
"@types/history" "*"
"@types/react" "*"

"@types/react@*", "@types/react@^17.0.14", "@types/react@^17.0.2":
"@types/react@*", "@types/react@^17.0.2":
version "17.0.15"
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.15.tgz#c7533dc38025677e312606502df7656a6ea626d0"
integrity sha512-uTKHDK9STXFHLaKv6IMnwp52fm0hwU+N89w/p9grdUqcFA6WuqDyPhaWopbNyE1k/VhgzmHl8pu1L4wITtmlLw==
Expand Down