Skip to content

Commit d681bb3

Browse files
authored
Upgrade codebase to latest React, Redux, and TS (#10646)
* Bump React, RTK, TS, and others to latest * Fix TS target settings * Update React override types * Update Activity and JSX imports * Fix Picker types * Update ReactNode usages * Update Redux store types * Bump headlessui * Fix remaining TS issues * Bump nested React * Bump RTL and fix RDT fork for React 19 * Transform ESM packages * Replace act imports * Remove uses of `react-transition-group` * Remove react-transition-group * Bump Next to 15.x * Reset tsconfig
1 parent d1049ed commit d681bb3

69 files changed

Lines changed: 1163 additions & 553 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
diff --git a/dist/backend.js b/dist/backend.js
2+
index 3f760fc6b271b12d6ac05bcab347c0a6eea30e28..90a6da63c6cba3a3d8f4afd87e574c1b4515a60b 100644
3+
--- a/dist/backend.js
4+
+++ b/dist/backend.js
5+
@@ -5627,7 +5627,7 @@ const external_react_namespaceObject = require("react");
6+
*
7+
*/
8+
9+
-const ReactSharedInternals = external_react_namespaceObject.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
10+
+const ReactSharedInternals = external_react_namespaceObject.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED || (function() { var ni = external_react_namespaceObject.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; return ni ? { ReactCurrentDispatcher: { get current() { return ni.H; }, set current(v) { ni.H = v; } }, ReactCurrentOwner: { get current() { return ni.A; }, set current(v) { ni.A = v; } }, ReactCurrentBatchConfig: { get transition() { return ni.T; }, set transition(v) { ni.T = v; } } } : {}; })();
11+
/* harmony default export */ const shared_ReactSharedInternals = (ReactSharedInternals);
12+
;// CONCATENATED MODULE: ../react-reconciler/src/ReactWorkTags.js
13+
/**
14+
@@ -14841,8 +14841,8 @@ function initBackend(hook, agent, global) {
15+
let rendererInterface = hook.rendererInterfaces.get(id); // Inject any not-yet-injected renderers (if we didn't reload-and-profile)
16+
17+
if (rendererInterface == null) {
18+
- if (typeof renderer.findFiberByHostInstance === 'function') {
19+
- // react-reconciler v16+
20+
+ if (typeof renderer.findFiberByHostInstance === 'function' || typeof renderer.getCurrentFiber === 'function') {
21+
+ // react-reconciler v16+ (findFiberByHostInstance) or React 19+ (getCurrentFiber)
22+
rendererInterface = attach(hook, id, renderer, global);
23+
} else if (renderer.ComponentTree) {
24+
// react-dom v15
25+
diff --git a/dist/frontend.js b/dist/frontend.js
26+
index 3cee5fd2a7483b4bf3d742e824a9a4af668c7a17..4ba7a1c940cf390e8006432758a4e077f86f69d2 100644
27+
--- a/dist/frontend.js
28+
+++ b/dist/frontend.js
29+
@@ -23242,7 +23242,7 @@ function Button_Button({
30+
const Pending = 0;
31+
const Resolved = 1;
32+
const Rejected = 2;
33+
-const ReactCurrentDispatcher = external_react_namespaceObject.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher;
34+
+const ReactCurrentDispatcher = (external_react_namespaceObject.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED || {}).ReactCurrentDispatcher || { get current() { return (external_react_namespaceObject.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE || {}).H; }, set current(v) { (external_react_namespaceObject.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE || {}).H = v; } };
35+
36+
function readContext(Context) {
37+
const dispatcher = ReactCurrentDispatcher.current;

jest.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ module.exports = {
7272
// Handle text file imports
7373
"^.+\\.properties$": "<rootDir>/test/jest/jest-text-transformer.js",
7474
},
75-
transformIgnorePatterns: ["/node_modules/", "^.+\\.module\\.(css|sass|scss)$"],
75+
transformIgnorePatterns: [
76+
"/node_modules/(?!(suspense|array-sorting-utilities|interval-utilities|point-utilities)/)",
77+
"^.+\\.module\\.(css|sass|scss)$",
78+
],
7679
setupFilesAfterEnv: ["<rootDir>/test/jest/setupEnv.js"],
7780
};

package.json

Lines changed: 20 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/accordion/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,10 @@ export const Accordion: FC<{
149149
};
150150
}
151151

152+
const props = (c as ReactElement).props as Record<string, any>;
152153
return {
153-
expanded: !!(c as ReactElement).props.expanded ?? false,
154-
initialHeight: (c as ReactElement).props.initialHeight,
154+
expanded: !!props.expanded,
155+
initialHeight: props.initialHeight,
155156
};
156157
});
157158
const [state, dispatch] = useReducer(reducer, getInitialState(initialState!));

packages/accordion/website/package.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/design/AddCommentButton/index.tsx

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import classNames from "classnames";
22
import type { MouseEventHandler } from "react";
33
import { forwardRef, useRef, useState } from "react";
44
import mergeRefs from "react-merge-refs";
5-
import { Transition } from "react-transition-group";
65

76
import { Icon } from "design/Icon";
87

@@ -67,23 +66,15 @@ export const AddCommentButton = forwardRef<HTMLButtonElement, AddCommentButtonPr
6766
}
6867
);
6968

70-
// Duration must match `transition` rule in module.css file
71-
const duration = 100;
72-
73-
const states = {
74-
entering: { opacity: 0, transform: "scale(0.98)" },
75-
entered: { opacity: 1, transform: "scale(1)" },
76-
exiting: { opacity: 0, transform: "scale(0.98)" },
77-
exited: { display: "none", opacity: 0, transform: "scale(0.98)" },
78-
unmounted: { display: "none", opacity: 0, transform: "scale(0.98)" },
79-
};
80-
8169
const TextFade = ({ children, visible }: { children: React.ReactNode; visible: boolean }) => (
82-
<Transition in={visible} timeout={duration}>
83-
{state => (
84-
<span className={styles.TextFade} style={states[state]}>
85-
{children}
86-
</span>
87-
)}
88-
</Transition>
70+
<span
71+
className={styles.TextFade}
72+
style={
73+
visible
74+
? { opacity: 1, transform: "scale(1)" }
75+
: { display: "none", opacity: 0, transform: "scale(0.98)" }
76+
}
77+
>
78+
{children}
79+
</span>
8980
);

packages/design/PrefixBadgePicker/Picker.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,20 @@ export function Picker<Values extends any>({
6666
throw Error("Picker children must be a valid React element.");
6767
}
6868

69+
// @ts-expect-error Can't enforce props type
6970
if (!child.props.id) {
7071
const name = typeof child.type === "string" ? child.type : child.type.name;
7172
throw Error(`Immediate Picker child "${name}" must pass an "id" prop.`);
7273
}
7374

75+
// @ts-expect-error Can't enforce props type
7476
const isToggle = child.props.id === "toggle";
7577
const showToggle = value === undefined && isToggle;
78+
// @ts-expect-error Can't enforce props type
7679
const isChildActive = value === child.props.id || showToggle;
80+
// @ts-expect-error Can't enforce props type
7781
const wasChildActive = previousId.current === child.props.id;
82+
// @ts-expect-error Can't enforce props type
7883
const childVariants = child.props.variants || {};
7984
const onSelect = () => {
8085
const nextIsOpen = !isOpen;
@@ -93,8 +98,10 @@ export function Picker<Values extends any>({
9398
transitioning.current = true;
9499
}
95100

101+
// @ts-expect-error Can't enforce props type
96102
const nextActiveId = isToggle ? undefined : child.props.id;
97103

104+
// @ts-expect-error Can't enforce props type
98105
previousId.current = isChildActive ? child.props.id : undefined;
99106

100107
onChange(nextActiveId);
@@ -116,12 +123,14 @@ export function Picker<Values extends any>({
116123
},
117124
transition: {
118125
...transition,
126+
// @ts-expect-error Can't enforce props type
119127
...child.props.transition,
120128
},
121129
style: {
122130
zIndex: isChildActive || wasChildActive ? 10 : 1,
123131
gridColumn: isOpen ? undefined : 1,
124132
gridRow: 1,
133+
// @ts-expect-error Can't enforce props type
125134
...child.props.style,
126135
},
127136
onClick: onSelect,

packages/replay-next/components/LazyActivity.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { unstable_Activity as Activity, ReactNode, useEffect, useRef } from "react";
1+
import { Activity, ReactNode, useEffect, useRef } from "react";
22

33
// Wrapper around the Activity API that defers rendering the Activity tree initially,
44
// until it's been explicitly marked as "visible".

packages/replay-next/components/Popup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default function Popup({
2424
}: Omit<HTMLAttributes<HTMLDivElement>, "onClick"> & {
2525
children: ReactNode;
2626
clientX?: number | null;
27-
containerRef?: RefObject<HTMLElement> | null;
27+
containerRef?: RefObject<HTMLElement | null> | null;
2828
dismiss: Dismiss;
2929
dismissOnMouseLeave?: boolean;
3030
horizontalAlignment?: "left" | "center" | "right";

packages/replay-next/components/console/ConsoleInput.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ import EagerEvaluationResult from "./EagerEvaluationResult";
2222
import useTerminalHistory from "./hooks/useTerminalHistory";
2323
import styles from "./ConsoleInput.module.css";
2424

25-
export default function ConsoleInput({ inputRef }: { inputRef?: RefObject<ImperativeHandle> }) {
25+
export default function ConsoleInput({
26+
inputRef,
27+
}: {
28+
inputRef?: RefObject<ImperativeHandle | null>;
29+
}) {
2630
const { executionPoint } = useContext(TimelineContext);
2731
const { enterFocusMode } = useContext(FocusContext);
2832

@@ -69,7 +73,7 @@ export default function ConsoleInput({ inputRef }: { inputRef?: RefObject<Impera
6973
);
7074
}
7175

72-
function ConsoleInputSuspends({ inputRef }: { inputRef?: RefObject<ImperativeHandle> }) {
76+
function ConsoleInputSuspends({ inputRef }: { inputRef?: RefObject<ImperativeHandle | null> }) {
7377
const [searchState] = useContext(ConsoleSearchContext);
7478
const { selectedPauseAndFrameId } = useContext(SelectedFrameContext);
7579
const replayClient = useContext(ReplayClientContext);

0 commit comments

Comments
 (0)