Skip to content

Commit b3c8f5c

Browse files
authored
feat: Docusaurus v3 upgrades and require TypeScript 5 (#9258)
1 parent da85e22 commit b3c8f5c

File tree

26 files changed

+41
-26
lines changed

26 files changed

+41
-26
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"@testing-library/react-hooks": "^8.0.1",
7373
"@types/fs-extra": "^9.0.13",
7474
"@types/jest": "^29.5.3",
75-
"@types/lodash": "^4.14.195",
75+
"@types/lodash": "^4.14.197",
7676
"@types/node": "^18.16.19",
7777
"@types/prompts": "^2.4.4",
7878
"@types/react": "^18.2.15",
@@ -116,6 +116,6 @@
116116
"stylelint": "^14.16.1",
117117
"stylelint-config-prettier": "^9.0.5",
118118
"stylelint-config-standard": "^29.0.0",
119-
"typescript": "~5.0.4"
119+
"typescript": "~5.2.2"
120120
}
121121
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"devDependencies": {
2727
"@docusaurus/module-type-aliases": "3.0.0-alpha.0",
2828
"@docusaurus/tsconfig": "3.0.0-alpha.0",
29-
"typescript": "~5.0.4"
29+
"typescript": "~5.2.2"
3030
},
3131
"browserslist": {
3232
"production": [

packages/docusaurus-plugin-content-docs/tsconfig.client.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"composite": true,
66
"incremental": true,
77
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
8+
"moduleResolution": "bundler",
89
"module": "esnext",
910
"target": "esnext",
1011
"rootDir": "src",

packages/docusaurus-plugin-debug/tsconfig.client.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"composite": true,
66
"incremental": true,
77
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
8+
"moduleResolution": "bundler",
89
"module": "esnext",
910
"target": "esnext",
1011
"rootDir": "src",

packages/docusaurus-plugin-google-analytics/tsconfig.client.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"composite": true,
66
"incremental": true,
77
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
8+
"moduleResolution": "bundler",
89
"module": "esnext",
910
"target": "esnext",
1011
"rootDir": "src",

packages/docusaurus-plugin-google-gtag/tsconfig.client.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"composite": true,
66
"incremental": true,
77
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
8+
"moduleResolution": "bundler",
89
"module": "esnext",
910
"target": "esnext",
1011
"rootDir": "src",

packages/docusaurus-plugin-google-tag-manager/tsconfig.client.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"composite": true,
66
"incremental": true,
77
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
8+
"moduleResolution": "bundler",
89
"module": "esnext",
910
"target": "esnext",
1011
"rootDir": "src",

packages/docusaurus-plugin-ideal-image/tsconfig.client.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"composite": true,
66
"incremental": true,
77
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
8+
"moduleResolution": "bundler",
89
"module": "esnext",
910
"target": "esnext",
1011
"rootDir": "src",

packages/docusaurus-plugin-pwa/tsconfig.client.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
88
"rootDir": "src",
99
"outDir": "lib",
10+
"moduleResolution": "bundler",
1011
"module": "esnext",
1112
"target": "esnext"
1213
},

packages/docusaurus-plugin-pwa/tsconfig.worker.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"tsBuildInfoFile": "./lib/.tsbuildinfo-worker",
99
"rootDir": "src",
1010
"outDir": "lib",
11+
"moduleResolution": "bundler",
1112
"module": "esnext",
1213
"target": "esnext",
1314
"types": ["node"]

packages/docusaurus-theme-classic/src/theme-classic.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,11 @@ declare module '@theme/MDXComponents' {
891891
import type Mermaid from '@theme/Mermaid';
892892
import type Head from '@docusaurus/Head';
893893

894-
export type MDXComponentsObject = {
894+
import type {MDXProvider} from '@mdx-js/react';
895+
896+
type MDXComponentsBase = ComponentProps<typeof MDXProvider>['components'];
897+
898+
export type MDXComponentsObject = MDXComponentsBase & {
895899
readonly Head: typeof Head;
896900
readonly details: typeof MDXDetails;
897901

packages/docusaurus-theme-classic/src/theme/CodeBlock/CopyButton/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import React, {useCallback, useState, useRef, useEffect} from 'react';
99
import clsx from 'clsx';
10-
// @ts-expect-error: TODO, we need to make theme-classic have type: module
1110
import copy from 'copy-text-to-clipboard';
1211
import {translate} from '@docusaurus/Translate';
1312
import type {Props} from '@theme/CodeBlock/CopyButton';

packages/docusaurus-theme-classic/src/theme/MDXComponents/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import React from 'react';
8+
import React, {type ComponentProps} from 'react';
99
import Head from '@docusaurus/Head';
1010
import MDXCode from '@theme/MDXComponents/Code';
1111
import MDXA from '@theme/MDXComponents/A';
@@ -28,12 +28,12 @@ const MDXComponents: MDXComponentsObject = {
2828
pre: MDXPre,
2929
ul: MDXUl,
3030
img: MDXImg,
31-
h1: (props) => <MDXHeading as="h1" {...props} />,
32-
h2: (props) => <MDXHeading as="h2" {...props} />,
33-
h3: (props) => <MDXHeading as="h3" {...props} />,
34-
h4: (props) => <MDXHeading as="h4" {...props} />,
35-
h5: (props) => <MDXHeading as="h5" {...props} />,
36-
h6: (props) => <MDXHeading as="h6" {...props} />,
31+
h1: (props: ComponentProps<'h1'>) => <MDXHeading as="h1" {...props} />,
32+
h2: (props: ComponentProps<'h2'>) => <MDXHeading as="h2" {...props} />,
33+
h3: (props: ComponentProps<'h3'>) => <MDXHeading as="h3" {...props} />,
34+
h4: (props: ComponentProps<'h4'>) => <MDXHeading as="h4" {...props} />,
35+
h5: (props: ComponentProps<'h5'>) => <MDXHeading as="h5" {...props} />,
36+
h6: (props: ComponentProps<'h6'>) => <MDXHeading as="h6" {...props} />,
3737
admonition: Admonition,
3838
mermaid: Mermaid,
3939
};

packages/docusaurus-theme-classic/src/theme/MDXContent/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
import React from 'react';
9-
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
109
import {MDXProvider} from '@mdx-js/react';
1110
import MDXComponents from '@theme/MDXComponents';
1211
import type {Props} from '@theme/MDXContent';

packages/docusaurus-theme-classic/tsconfig.client.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
88
"rootDir": "src",
99
"outDir": "lib",
10+
"moduleResolution": "bundler",
1011
"module": "esnext",
1112
"target": "esnext"
1213
},

packages/docusaurus-theme-common/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"noEmit": false,
55
"incremental": true,
66
"tsBuildInfoFile": "./lib/.tsbuildinfo",
7+
"moduleResolution": "bundler",
78
"module": "esnext",
89
"target": "esnext",
910
"sourceMap": true,

packages/docusaurus-theme-live-codeblock/tsconfig.client.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
88
"rootDir": "src",
99
"outDir": "lib",
10+
"moduleResolution": "bundler",
1011
"module": "esnext",
1112
"target": "esnext"
1213
},

packages/docusaurus-theme-mermaid/tsconfig.client.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
88
"rootDir": "src",
99
"outDir": "lib",
10+
"moduleResolution": "bundler",
1011
"module": "esnext",
1112
"target": "esnext"
1213
},

packages/docusaurus-theme-mermaid/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"noEmit": false,
66
"incremental": true,
77
"tsBuildInfoFile": "./lib/.tsbuildinfo",
8-
"module": "commonjs",
98
"rootDir": "src",
109
"outDir": "lib"
1110
},

packages/docusaurus-theme-search-algolia/tsconfig.client.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
88
"rootDir": "src",
99
"outDir": "lib",
10+
"moduleResolution": "bundler",
1011
"module": "esnext",
1112
"target": "esnext"
1213
},

packages/docusaurus-tsconfig/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"esModuleInterop": true,
88
"jsx": "preserve",
99
"lib": ["DOM"],
10-
"moduleResolution": "Node16",
10+
"moduleResolution": "bundler",
11+
"module": "esnext",
1112
"noEmit": true,
1213
"types": [
1314
"node",

packages/docusaurus/tsconfig.client.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"composite": true,
66
"incremental": true,
77
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
8+
"moduleResolution": "bundler",
89
"module": "esnext",
910
"target": "esnext",
1011
"rootDir": "src",

website/_dogfooding/_pages tests/react-18/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import Layout from '@theme/Layout';
1111
import Heading from '@theme/Heading';
1212

1313
const HeavyComponentLazy = React.lazy(
14-
// @ts-expect-error: not sure why TS is unhappy about this...
1514
() => import('./_components/heavyComponent'),
1615
);
1716

website/docusaurus.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
const path = require('path');
1010
const npm2yarn = require('@docusaurus/remark-plugin-npm2yarn');
11+
/** @type {Array<string>} */
1112
const versions = require('./versions.json');
13+
/** @type {Record<string,string>} */
1214
const VersionsArchived = require('./versionsArchived.json');
1315
const {
1416
dogfoodingPluginInstances,

website/tsconfig.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
"noUnusedParameters": false,
2929
"importsNotUsedAsValues": "remove",
3030

31-
"moduleResolution": "NodeNext",
32-
3331
// This is important. We run `yarn tsc` in website so we can catch issues
3432
// with our declaration files (mostly names that are forgotten to be
3533
// imported, invalid semantics...). Because we don't have end-to-end type

yarn.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3396,10 +3396,10 @@
33963396
resolved "https://registry.yarnpkg.com/@types/katex/-/katex-0.16.1.tgz#e1faa29f131c241a7669e65bdf8ce470c9c4e3a9"
33973397
integrity sha512-cwglq2A63Yk082CQk0t8LIoDhZAVgJqkumLyk3grpg3K8sevaDW//Qsspmxj9Sf+97biqt79CfAlPrvizHlP0w==
33983398

3399-
"@types/lodash@^4.14.195":
3400-
version "4.14.195"
3401-
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.195.tgz#bafc975b252eb6cea78882ce8a7b6bf22a6de632"
3402-
integrity sha512-Hwx9EUgdwf2GLarOjQp5ZH8ZmblzcbTBC2wtQWNKARBSxM9ezRIAUpeDTgoQRAFB0+8CNWXVA9+MaSOzOF3nPg==
3399+
"@types/lodash@^4.14.197":
3400+
version "4.14.197"
3401+
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.197.tgz#e95c5ddcc814ec3e84c891910a01e0c8a378c54b"
3402+
integrity sha512-BMVOiWs0uNxHVlHBgzTIqJYmj+PgCo4euloGF+5m4okL3rEYzM2EEv78mw8zWSMM57dM7kVIgJ2QDvwHSoCI5g==
34033403

34043404
"@types/mdast@^3.0.0", "@types/mdast@^3.0.12":
34053405
version "3.0.12"
@@ -16320,10 +16320,10 @@ typedarray@^0.0.6:
1632016320
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a"
1632116321
integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==
1632216322

16323-
typescript@~5.0.4:
16324-
version "5.0.4"
16325-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b"
16326-
integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==
16323+
typescript@~5.2.2:
16324+
version "5.2.2"
16325+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.2.tgz#5ebb5e5a5b75f085f22bc3f8460fba308310fa78"
16326+
integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==
1632716327

1632816328
ua-parser-js@^1.0.35:
1632916329
version "1.0.35"

0 commit comments

Comments
 (0)