Skip to content

Commit 53de0f7

Browse files
authored
[Beta] Upgrade React Types & Fix resulting type issues (#4694)
* upgrade react types * fix type errors after upgrade
1 parent cec374f commit 53de0f7

File tree

7 files changed

+22
-19
lines changed

7 files changed

+22
-19
lines changed

beta/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
"@types/mdx-js__react": "^1.5.2",
4949
"@types/node": "^14.6.4",
5050
"@types/parse-numeric-range": "^0.0.1",
51-
"@types/react": "^16.9.46",
52-
"@types/react-dom": "^16.9.8",
51+
"@types/react": "^18.0.9",
52+
"@types/react-dom": "^18.0.5",
5353
"@typescript-eslint/eslint-plugin": "2.x",
5454
"@typescript-eslint/parser": "2.x",
5555
"asyncro": "^3.0.0",

beta/src/components/Layout/useMediaQuery.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {useState, useCallback, useEffect} from 'react';
77
const useMediaQuery = (width: number) => {
88
const [targetReached, setTargetReached] = useState(false);
99

10-
const updateTarget = useCallback((e) => {
10+
const updateTarget = useCallback((e: MediaQueryListEvent) => {
1111
if (e.matches) {
1212
setTargetReached(true);
1313
} else {

beta/src/components/MDX/Sandpack/DownloadButton.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ let supportsImportMap: boolean | void;
1212
function useSupportsImportMap() {
1313
function subscribe() {
1414
// It never updates.
15+
return () => {};
1516
}
1617
function getCurrentValue() {
1718
if (supportsImportMap === undefined) {
@@ -24,7 +25,7 @@ function useSupportsImportMap() {
2425
function getServerSnapshot() {
2526
return false;
2627
}
27-
// @ts-ignore
28+
2829
return React.useSyncExternalStore(
2930
subscribe,
3031
getCurrentValue,

beta/src/components/MDX/Sandpack/SandpackRoot.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {createFileMap} from './createFileMap';
1111
import type {SandpackSetup} from '@codesandbox/sandpack-react';
1212

1313
type SandpackProps = {
14-
children: React.ReactChildren;
14+
children: React.ReactNode;
1515
autorun?: boolean;
1616
setup?: SandpackSetup;
1717
showDevTools?: boolean;

beta/src/pages/_app.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import '../styles/index.css';
1212
import '../styles/sandpack.css';
1313
import '@codesandbox/sandpack-react/dist/index.css';
1414

15-
const EmptyAppShell: React.FC = ({children}) => <>{children}</>;
15+
const EmptyAppShell = ({children}: {children: React.ReactNode}) => (
16+
<>{children}</>
17+
);
1618

1719
if (typeof window !== 'undefined') {
1820
if (process.env.NODE_ENV === 'production') {

beta/src/utils/toCommaSeparatedList.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44

55
import React from 'react';
66

7-
const addString = (list: React.ReactNodeArray, string: string) =>
7+
const addString = (list: React.ReactNode[], string: string) =>
88
list.push(<span key={`${list.length}-${string}`}>{string}</span>);
99

1010
function toCommaSeparatedList<Item>(
1111
array: Item[],
12-
renderCallback: (item: Item, index: number) => void
13-
): Array<any> {
12+
renderCallback: (item: Item, index: number) => React.ReactNode
13+
): React.ReactNode[] {
1414
if (array.length <= 1) {
1515
return array.map(renderCallback);
1616
}
1717

18-
const list: any = [];
18+
const list: React.ReactNode[] = [];
1919

2020
array.forEach((item, index) => {
2121
if (index === array.length - 1) {

beta/yarn.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -912,12 +912,12 @@
912912
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.4.tgz#fcf7205c25dff795ee79af1e30da2c9790808f11"
913913
integrity sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ==
914914

915-
"@types/react-dom@^16.9.8":
916-
version "16.9.14"
917-
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.14.tgz#674b8f116645fe5266b40b525777fc6bb8eb3bcd"
918-
integrity sha512-FIX2AVmPTGP30OUJ+0vadeIFJJ07Mh1m+U0rxfgyW34p3rTlXI+nlenvAxNn4BP36YyI9IJ/+UJ7Wu22N1pI7A==
915+
"@types/react-dom@^18.0.5":
916+
version "18.0.5"
917+
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.0.5.tgz#330b2d472c22f796e5531446939eacef8378444a"
918+
integrity sha512-OWPWTUrY/NIrjsAPkAk1wW9LZeIjSvkXRhclsFO8CZcZGCOg2G0YZy4ft+rOyYxy8B7ui5iZzi9OkDebZ7/QSA==
919919
dependencies:
920-
"@types/react" "^16"
920+
"@types/react" "*"
921921

922922
"@types/react@*":
923923
version "17.0.38"
@@ -928,10 +928,10 @@
928928
"@types/scheduler" "*"
929929
csstype "^3.0.2"
930930

931-
"@types/react@^16", "@types/react@^16.9.46":
932-
version "16.14.21"
933-
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.14.21.tgz#35199b21a278355ec7a3c40003bd6a334bd4ae4a"
934-
integrity sha512-rY4DzPKK/4aohyWiDRHS2fotN5rhBSK6/rz1X37KzNna9HJyqtaGAbq9fVttrEPWF5ywpfIP1ITL8Xi2QZn6Eg==
931+
"@types/react@^18.0.9":
932+
version "18.0.9"
933+
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.9.tgz#d6712a38bd6cd83469603e7359511126f122e878"
934+
integrity sha512-9bjbg1hJHUm4De19L1cHiW0Jvx3geel6Qczhjd0qY5VKVE2X5+x77YxAepuCwVh4vrgZJdgEJw48zrhRIeF4Nw==
935935
dependencies:
936936
"@types/prop-types" "*"
937937
"@types/scheduler" "*"

0 commit comments

Comments
 (0)