Skip to content

Commit 4a0273f

Browse files
authored
fix(create-docusaurus): fix support for TypeScript 6.0 + fix our CI (#11843)
1 parent a0765a0 commit 4a0273f

23 files changed

Lines changed: 75 additions & 53 deletions

File tree

.github/workflows/tests-e2e.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,18 +158,28 @@ jobs:
158158
working-directory: ../test-website
159159
env:
160160
E2E_TEST: true
161+
161162
- name: TypeCheck website
162163
# TODO: there're some lingering issues with PnP + tsc. Enable tsc in PnP later.
163164
if: matrix.variant == '-st' && matrix.nodeLinker != 'pnp'
164165
working-directory: ../test-website
165166
run: yarn typecheck
167+
166168
- name: TypeCheck website - min version - v5.1
167169
# TODO: there're some lingering issues with PnP + tsc. Enable tsc in PnP later.
168170
if: matrix.variant == '-st' && matrix.nodeLinker != 'pnp'
169171
working-directory: ../test-website
170172
run: |
171173
yarn add typescript@5.1.6 --exact
174+
175+
# Downgrade TS ignoreDeprecations option
176+
node -e "const fs = require('fs'); const f = 'tsconfig.json'; fs.writeFileSync(f, fs.readFileSync(f,'utf8').replace('\"ignoreDeprecations\": \"6.0\"', '\"ignoreDeprecations\": \"5.0\"'))"
177+
172178
yarn typecheck
179+
180+
# Restore TS ignoreDeprecations option
181+
node -e "const fs = require('fs'); const f = 'tsconfig.json'; fs.writeFileSync(f, fs.readFileSync(f,'utf8').replace('\"ignoreDeprecations\": \"5.0\"', '\"ignoreDeprecations\": \"6.0\"'))"
182+
173183
- name: TypeCheck website - max version - Latest
174184
# TODO: there're some lingering issues with PnP + tsc. Enable tsc in PnP later.
175185
if: matrix.variant == '-st' && matrix.nodeLinker != 'pnp'

.github/workflows/tests-windows.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,23 @@ jobs:
6161
- name: TypeCheck website
6262
# see https://github.com/facebook/docusaurus/pull/10486
6363
run: yarn workspace website typecheck
64+
65+
- name: TypeCheck website - max version - Latest
66+
# For latest TS there are often lib check errors, so we disable it
67+
# Details: https://github.com/facebook/docusaurus/pull/10486
68+
run: |
69+
yarn add typescript@latest --exact -D -W --ignore-scripts
70+
yarn workspace website typecheck --project tsconfig.skipLibCheck.json
71+
6472
- name: TypeCheck website - min version - v5.1
6573
run: |
6674
yarn add typescript@5.1.6 --exact -D -W --ignore-scripts
6775
76+
# Downgrade TS ignoreDeprecations option
77+
node -e 'const fs = require("fs"); const f = "website/tsconfig.json"; fs.writeFileSync(f, fs.readFileSync(f, "utf8").replace(/"ignoreDeprecations"\s*:\s*"6\.0"/, "\"ignoreDeprecations\": \"5.0\""));'
78+
6879
# DocSearch@4/ai@5 doesn't support TS 5.1 (with skipLibCheck=false)
6980
jq '.resolutions."@docsearch/react" = "^3.9.0"' package.json > package.json.tmp && mv -Force package.json.tmp package.json
7081
yarn add @docsearch/react@^3.9.0 --exact -D -W --ignore-scripts
7182
7283
yarn workspace website typecheck
73-
- name: TypeCheck website - max version - Latest
74-
# For latest TS there are often lib check errors, so we disable it
75-
# Details: https://github.com/facebook/docusaurus/pull/10486
76-
run: |
77-
yarn add typescript@latest --exact -D -W --ignore-scripts
78-
yarn workspace website typecheck --project tsconfig.skipLibCheck.json

.github/workflows/tests.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,23 @@ jobs:
5858
- name: TypeCheck website
5959
# see https://github.com/facebook/docusaurus/pull/10486
6060
run: yarn workspace website typecheck
61+
6162
- name: TypeCheck website - min version - v5.1
6263
run: |
6364
yarn add typescript@5.1.6 --exact -D -W --ignore-scripts
6465
66+
# Downgrade TS ignoreDeprecations option
67+
node -e "const fs = require('fs'); const f = 'website/tsconfig.json'; fs.writeFileSync(f, fs.readFileSync(f,'utf8').replace('\"ignoreDeprecations\": \"6.0\"', '\"ignoreDeprecations\": \"5.0\"'))"
68+
6569
# DocSearch@4/ai@5 doesn't support TS 5.1 (with skipLibCheck=false)
6670
jq '.resolutions."@docsearch/react" = "^3.9.0"' package.json > package.json.tmp && mv -f package.json.tmp package.json
6771
yarn add @docsearch/react@^3.9.0 --exact -D -W --ignore-scripts
6872
6973
yarn workspace website typecheck
74+
75+
# Restore TS ignoreDeprecations option
76+
node -e "const fs = require('fs'); const f = 'website/tsconfig.json'; fs.writeFileSync(f, fs.readFileSync(f,'utf8').replace('\"ignoreDeprecations\": \"5.0\"', '\"ignoreDeprecations\": \"6.0\"'))"
77+
7078
- name: TypeCheck website - max version - Latest
7179
# For latest TS there are often lib check errors, so we disable it
7280
# Details: https://github.com/facebook/docusaurus/pull/10486

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"@types/fs-extra": "^9.0.13",
8787
"@types/jest": "^30.0.0",
8888
"@types/lodash": "^4.14.197",
89-
"@types/node": "^18.16.19",
89+
"@types/node": "^20.19.37",
9090
"@types/prompts": "^2.4.4",
9191
"@types/react": "^19.2.10",
9292
"@types/semver": "^7.5.0",
@@ -128,7 +128,7 @@
128128
"stylelint": "^14.16.1",
129129
"stylelint-config-prettier": "^9.0.5",
130130
"stylelint-config-standard": "^29.0.0",
131-
"typescript": "~5.8.2"
131+
"typescript": "~6.0.2"
132132
},
133133
"resolutions": {
134134
"**/pretty-format/react-is": "^19.2.4"

packages/create-docusaurus/templates/classic-typescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"@docusaurus/tsconfig": "3.9.2",
3030
"@docusaurus/types": "3.9.2",
3131
"@types/react": "^19.0.0",
32-
"typescript": "~5.6.2"
32+
"typescript": "~6.0.2"
3333
},
3434
"browserslist": {
3535
"production": [

packages/create-docusaurus/templates/classic-typescript/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"extends": "@docusaurus/tsconfig",
66
"compilerOptions": {
77
"baseUrl": ".",
8+
"ignoreDeprecations": "6.0",
89
"strict": true
910
},
1011
"exclude": [".docusaurus", "build"]

packages/docusaurus-logger/src/perfLogger.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
7-
import {AsyncLocalStorage} from 'async_hooks';
7+
8+
import {AsyncLocalStorage} from 'node:async_hooks';
9+
import {type PerformanceMark} from 'node:perf_hooks';
810
import logger from './logger';
911

1012
// For now this is a private env variable we use internally
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"extends": "../../tsconfig.base.client.json",
33
"include": ["src/client", "src/*.d.ts"],
4-
"exclude": ["**/__tests__/**"]
4+
"exclude": ["**/__tests__/**", "**/*.test.ts"]
55
}

packages/docusaurus-plugin-content-blog/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
"noEmit": false
66
},
77
"include": ["src"],
8-
"exclude": ["src/client", "**/__tests__/**"]
8+
"exclude": ["src/client", "**/__tests__/**", "**/*.test.ts"]
99
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"extends": "../../tsconfig.base.client.json",
33
"include": ["src/client", "src/*.d.ts"],
4-
"exclude": ["**/__tests__/**"]
4+
"exclude": ["**/__tests__/**", "**/*.test.ts"]
55
}

0 commit comments

Comments
 (0)