Skip to content

Commit a02e9d1

Browse files
authored
refactor: prepare react 19 types (#4553)
React 19 simplified ref object story, moved JSX from global into react package. Here prepared our code to not refactor too much in packages bump.
1 parent 64b8abb commit a02e9d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+92
-68
lines changed

@types/canvas-iframe.d.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
declare namespace JSX {
2-
interface IntrinsicElements {
3-
iframe: React.DetailedHTMLProps<
4-
React.IframeHTMLAttributes<HTMLIFrameElement> & {
5-
credentialless?: "true";
6-
},
7-
HTMLIFrameElement
8-
>;
1+
declare namespace React {
2+
interface IframeHTMLAttributes {
3+
credentialless?: "true";
94
}
105
}

apps/builder/app/auth/brand-button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { css, textVariants, theme } from "@webstudio-is/design-system";
2-
import type { ComponentProps } from "react";
2+
import type { ComponentProps, JSX } from "react";
33

44
export const buttonStyle = css({
55
boxSizing: "border-box",

apps/builder/app/auth/login.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { JSX } from "react";
12
import type { StoryFn } from "@storybook/react";
23
import { createBrowserRouter, RouterProvider } from "react-router-dom";
34
import { Login } from "./login";

apps/builder/app/builder/builder.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useMemo, useState, type ReactNode } from "react";
1+
import { useEffect, useMemo, useState, type JSX, type ReactNode } from "react";
22
import { useStore } from "@nanostores/react";
33
import { TooltipProvider } from "@radix-ui/react-tooltip";
44
import { usePublish, $publisher } from "~/shared/pubsub";

apps/builder/app/builder/features/address-bar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ const Suggestions = ({
143143
options,
144144
onSelect,
145145
}: {
146-
containerRef: RefObject<HTMLFormElement>;
146+
containerRef: RefObject<null | HTMLFormElement>;
147147
options: string[];
148148
onSelect: (option: string) => void;
149149
}) => {

apps/builder/app/builder/features/ai/ai-command-bar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const AiCommandBar = () => {
7171

7272
const [isAudioTranscribing, setIsAudioTranscribing] = useState(false);
7373
const [isAiRequesting, setIsAiRequesting] = useState(false);
74-
const abortController = useRef<AbortController>();
74+
const abortController = useRef<undefined | AbortController>(undefined);
7575
const recordButtonRef = useRef<HTMLButtonElement>(null);
7676
const guardIdRef = useRef(0);
7777
const { enableCanvasPointerEvents, disableCanvasPointerEvents } =

apps/builder/app/builder/features/ai/hooks/long-press-toggle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type UseClickAndHoldProps = {
1515
* - `onCancel`: Pointer up outside target during long press.
1616
*/
1717
export const useLongPressToggle = (props: UseClickAndHoldProps) => {
18-
const currentTarget = useRef<Element>();
18+
const currentTarget = useRef<undefined | Element>(undefined);
1919
const pointerDownTimeRef = useRef(0);
2020
const stateRef = useRef<"idle" | "active">("idle");
2121
const keyMapRef = useRef(new Set<string>());

apps/builder/app/builder/features/ai/hooks/media-recorder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const useMediaRecorder = (
1414
},
1515
options = DEFAULT_OPTIONS
1616
) => {
17-
const disposeRef = useRef<() => void>();
17+
const disposeRef = useRef<undefined | (() => void)>(undefined);
1818

1919
const cancelRef = useRef(false);
2020
const isActiveRef = useRef<boolean>(false);

apps/builder/app/builder/features/pages/folder-settings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { z } from "zod";
2-
import { type FocusEventHandler, useState, useCallback } from "react";
2+
import { type FocusEventHandler, useState, useCallback, type JSX } from "react";
33
import { useStore } from "@nanostores/react";
44
import { useDebouncedCallback } from "use-debounce";
55
import slugify from "slugify";

apps/builder/app/builder/features/pages/form.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { JSX } from "react";
2+
13
export const Form = ({
24
onSubmit,
35
children,

0 commit comments

Comments
 (0)