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: Docusaurus v3 upgrades and require TypeScript 5 #9258

Merged
merged 4 commits into from
Aug 25, 2023
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"@testing-library/react-hooks": "^8.0.1",
"@types/fs-extra": "^9.0.13",
"@types/jest": "^29.5.3",
"@types/lodash": "^4.14.195",
"@types/lodash": "^4.14.197",
"@types/node": "^18.16.19",
"@types/prompts": "^2.4.4",
"@types/react": "^18.2.15",
Expand Down Expand Up @@ -116,6 +116,6 @@
"stylelint": "^14.16.1",
"stylelint-config-prettier": "^9.0.5",
"stylelint-config-standard": "^29.0.0",
"typescript": "~5.0.4"
"typescript": "~5.2.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"devDependencies": {
"@docusaurus/module-type-aliases": "3.0.0-alpha.0",
"@docusaurus/tsconfig": "3.0.0-alpha.0",
"typescript": "~5.0.4"
"typescript": "~5.2.2"
},
"browserslist": {
"production": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"composite": true,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"moduleResolution": "bundler",
"module": "esnext",
"target": "esnext",
"rootDir": "src",
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-plugin-debug/tsconfig.client.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"composite": true,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"moduleResolution": "bundler",
"module": "esnext",
"target": "esnext",
"rootDir": "src",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"composite": true,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"moduleResolution": "bundler",
"module": "esnext",
"target": "esnext",
"rootDir": "src",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"composite": true,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"moduleResolution": "bundler",
"module": "esnext",
"target": "esnext",
"rootDir": "src",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"composite": true,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"moduleResolution": "bundler",
"module": "esnext",
"target": "esnext",
"rootDir": "src",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"composite": true,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"moduleResolution": "bundler",
"module": "esnext",
"target": "esnext",
"rootDir": "src",
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-plugin-pwa/tsconfig.client.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"rootDir": "src",
"outDir": "lib",
"moduleResolution": "bundler",
"module": "esnext",
"target": "esnext"
},
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-plugin-pwa/tsconfig.worker.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"tsBuildInfoFile": "./lib/.tsbuildinfo-worker",
"rootDir": "src",
"outDir": "lib",
"moduleResolution": "bundler",
"module": "esnext",
"target": "esnext",
"types": ["node"]
Expand Down
6 changes: 5 additions & 1 deletion packages/docusaurus-theme-classic/src/theme-classic.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,11 @@ declare module '@theme/MDXComponents' {
import type Mermaid from '@theme/Mermaid';
import type Head from '@docusaurus/Head';

export type MDXComponentsObject = {
import type {MDXProvider} from '@mdx-js/react';

type MDXComponentsBase = ComponentProps<typeof MDXProvider>['components'];

export type MDXComponentsObject = MDXComponentsBase & {
readonly Head: typeof Head;
readonly details: typeof MDXDetails;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import React, {useCallback, useState, useRef, useEffect} from 'react';
import clsx from 'clsx';
// @ts-expect-error: TODO, we need to make theme-classic have type: module
import copy from 'copy-text-to-clipboard';
import {translate} from '@docusaurus/Translate';
import type {Props} from '@theme/CodeBlock/CopyButton';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';
import React, {type ComponentProps} from 'react';
import Head from '@docusaurus/Head';
import MDXCode from '@theme/MDXComponents/Code';
import MDXA from '@theme/MDXComponents/A';
Expand All @@ -28,12 +28,12 @@ const MDXComponents: MDXComponentsObject = {
pre: MDXPre,
ul: MDXUl,
img: MDXImg,
h1: (props) => <MDXHeading as="h1" {...props} />,
h2: (props) => <MDXHeading as="h2" {...props} />,
h3: (props) => <MDXHeading as="h3" {...props} />,
h4: (props) => <MDXHeading as="h4" {...props} />,
h5: (props) => <MDXHeading as="h5" {...props} />,
h6: (props) => <MDXHeading as="h6" {...props} />,
h1: (props: ComponentProps<'h1'>) => <MDXHeading as="h1" {...props} />,
h2: (props: ComponentProps<'h2'>) => <MDXHeading as="h2" {...props} />,
h3: (props: ComponentProps<'h3'>) => <MDXHeading as="h3" {...props} />,
h4: (props: ComponentProps<'h4'>) => <MDXHeading as="h4" {...props} />,
h5: (props: ComponentProps<'h5'>) => <MDXHeading as="h5" {...props} />,
h6: (props: ComponentProps<'h6'>) => <MDXHeading as="h6" {...props} />,
admonition: Admonition,
mermaid: Mermaid,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import React from 'react';
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
import {MDXProvider} from '@mdx-js/react';
import MDXComponents from '@theme/MDXComponents';
import type {Props} from '@theme/MDXContent';
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-theme-classic/tsconfig.client.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"rootDir": "src",
"outDir": "lib",
"moduleResolution": "bundler",
"module": "esnext",
"target": "esnext"
},
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-theme-common/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"noEmit": false,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo",
"moduleResolution": "bundler",
"module": "esnext",
"target": "esnext",
"sourceMap": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"rootDir": "src",
"outDir": "lib",
"moduleResolution": "bundler",
"module": "esnext",
"target": "esnext"
},
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-theme-mermaid/tsconfig.client.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"rootDir": "src",
"outDir": "lib",
"moduleResolution": "bundler",
"module": "esnext",
"target": "esnext"
},
Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-theme-mermaid/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"noEmit": false,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo",
"module": "commonjs",
"rootDir": "src",
"outDir": "lib"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"rootDir": "src",
"outDir": "lib",
"moduleResolution": "bundler",
"module": "esnext",
"target": "esnext"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/docusaurus-tsconfig/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"esModuleInterop": true,
"jsx": "preserve",
"lib": ["DOM"],
"moduleResolution": "Node16",
"moduleResolution": "bundler",
"module": "esnext",
"noEmit": true,
"types": [
"node",
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus/tsconfig.client.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"composite": true,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"moduleResolution": "bundler",
"module": "esnext",
"target": "esnext",
"rootDir": "src",
Expand Down
1 change: 0 additions & 1 deletion website/_dogfooding/_pages tests/react-18/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import Layout from '@theme/Layout';
import Heading from '@theme/Heading';

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

Expand Down
2 changes: 2 additions & 0 deletions website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

const path = require('path');
const npm2yarn = require('@docusaurus/remark-plugin-npm2yarn');
/** @type {Array<string>} */
const versions = require('./versions.json');
/** @type {Record<string,string>} */
const VersionsArchived = require('./versionsArchived.json');
const {
dogfoodingPluginInstances,
Expand Down
2 changes: 0 additions & 2 deletions website/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
"noUnusedParameters": false,
"importsNotUsedAsValues": "remove",

"moduleResolution": "NodeNext",

// This is important. We run `yarn tsc` in website so we can catch issues
// with our declaration files (mostly names that are forgotten to be
// imported, invalid semantics...). Because we don't have end-to-end type
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3396,10 +3396,10 @@
resolved "https://registry.yarnpkg.com/@types/katex/-/katex-0.16.1.tgz#e1faa29f131c241a7669e65bdf8ce470c9c4e3a9"
integrity sha512-cwglq2A63Yk082CQk0t8LIoDhZAVgJqkumLyk3grpg3K8sevaDW//Qsspmxj9Sf+97biqt79CfAlPrvizHlP0w==

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

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

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

ua-parser-js@^1.0.35:
version "1.0.35"
Expand Down
Loading