Skip to content

Commit 4f997b8

Browse files
committed
types-codemod
1 parent 069655a commit 4f997b8

Some content is hidden

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

41 files changed

+68
-35
lines changed

site/src/components/Conditionals/ChooseOne.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
type FC,
44
type PropsWithChildren,
55
type ReactNode,
6+
type JSX,
67
} from "react";
78

89
export interface CondProps {

site/src/components/Icons/CoderIcon.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SvgIcon, { type SvgIconProps } from "@mui/material/SvgIcon";
2+
import type { JSX } from "react";
23

34
/**
45
* CoderIcon represents the cloud with brackets Coder brand icon. It does not

site/src/components/Icons/DockerIcon.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SvgIcon, { type SvgIconProps } from "@mui/material/SvgIcon";
2+
import type { JSX } from "react";
23

34
export const DockerIcon = (props: SvgIconProps): JSX.Element => (
45
<SvgIcon {...props} viewBox="0 0 32 32">

site/src/components/Icons/EditSquare.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SvgIcon, { type SvgIconProps } from "@mui/material/SvgIcon";
2+
import type { JSX } from "react";
23

34
export const EditSquare = (props: SvgIconProps): JSX.Element => (
45
<SvgIcon {...props} viewBox="0 0 48 48">

site/src/components/Icons/ErrorIcon.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SvgIcon, { type SvgIconProps } from "@mui/material/SvgIcon";
2+
import type { JSX } from "react";
23

34
export const ErrorIcon = (props: SvgIconProps): JSX.Element => (
45
<SvgIcon {...props} viewBox="0 0 24 24">

site/src/components/Icons/FileCopyIcon.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SvgIcon, { type SvgIconProps } from "@mui/material/SvgIcon";
2+
import type { JSX } from "react";
23

34
export const FileCopyIcon = (props: SvgIconProps): JSX.Element => (
45
<SvgIcon {...props} viewBox="0 0 20 20">

site/src/components/Icons/GitIcon.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SvgIcon, { type SvgIconProps } from "@mui/material/SvgIcon";
2+
import type { JSX } from "react";
23

34
export const GitIcon = (props: SvgIconProps): JSX.Element => (
45
<SvgIcon {...props} viewBox="0 0 96 96">

site/src/components/Icons/GitlabIcon.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SvgIcon, { type SvgIconProps } from "@mui/material/SvgIcon";
2+
import type { JSX } from "react";
23

34
export const GitlabIcon = (props: SvgIconProps): JSX.Element => (
45
<SvgIcon {...props} viewBox="0 0 194 186">

site/src/components/Icons/JetBrainsIcon.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SvgIcon, { type SvgIconProps } from "@mui/material/SvgIcon";
2+
import type { JSX } from "react";
23

34
export const JetBrainsIcon = (props: SvgIconProps): JSX.Element => (
45
<SvgIcon {...props} viewBox="0 0 100 100">

site/src/components/Icons/MarkdownIcon.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SvgIcon, { type SvgIconProps } from "@mui/material/SvgIcon";
2+
import type { JSX } from "react";
23

34
export const MarkdownIcon = (props: SvgIconProps): JSX.Element => (
45
<SvgIcon {...props} viewBox="0 0 32 32">

site/src/components/Icons/RocketIcon.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SvgIcon, { type SvgIconProps } from "@mui/material/SvgIcon";
2+
import type { JSX } from "react";
23

34
export const RocketIcon = (props: SvgIconProps): JSX.Element => (
45
<SvgIcon {...props} viewBox="0 0 24 24">

site/src/components/Icons/TerminalIcon.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SvgIcon, { type SvgIconProps } from "@mui/material/SvgIcon";
2+
import type { JSX } from "react";
23

34
export const TerminalIcon = (props: SvgIconProps): JSX.Element => (
45
<SvgIcon {...props} viewBox="0 0 24 24">

site/src/components/Icons/TerraformIcon.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SvgIcon, { type SvgIconProps } from "@mui/material/SvgIcon";
2+
import type { JSX } from "react";
23

34
export const TerraformIcon = (props: SvgIconProps): JSX.Element => (
45
<SvgIcon {...props} viewBox="0 0 32 32">

site/src/components/Icons/VSCodeIcon.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SvgIcon, { type SvgIconProps } from "@mui/material/SvgIcon";
2+
import type { JSX } from "react";
23

34
export const VSCodeIcon = (props: SvgIconProps): JSX.Element => (
45
<SvgIcon {...props} viewBox="0 0 100 100">

site/src/components/Icons/VSCodeInsidersIcon.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SvgIcon, { type SvgIconProps } from "@mui/material/SvgIcon";
2+
import type { JSX } from "react";
23

34
export const VSCodeInsidersIcon = (props: SvgIconProps): JSX.Element => (
45
<SvgIcon {...props} viewBox="0 0 256 256">

site/src/components/Margins/Margins.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const widthBySize: Record<Size, number> = {
1313
small: containerWidth / 3,
1414
};
1515

16-
type MarginsProps = JSX.IntrinsicElements["div"] & {
16+
type MarginsProps = React.ComponentProps<"div"> & {
1717
size?: Size;
1818
};
1919

site/src/components/MoreMenu/MoreMenu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
} from "react";
1717

1818
type MoreMenuContextValue = {
19-
triggerRef: React.RefObject<HTMLButtonElement>;
19+
triggerRef: React.RefObject<HTMLButtonElement | null>;
2020
close: () => void;
2121
open: () => void;
2222
isOpen: boolean;
@@ -61,7 +61,7 @@ export const MoreMenuTrigger: FC<HTMLProps<HTMLButtonElement>> = ({
6161
}) => {
6262
const menu = useMoreMenuContext();
6363

64-
return cloneElement(children as ReactElement, {
64+
return cloneElement(children as ReactElement<any>, {
6565
"aria-haspopup": "true",
6666
...props,
6767
ref: menu.triggerRef,

site/src/components/Popover/Popover.tsx

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121

2222
type TriggerMode = "hover" | "click";
2323

24-
type TriggerRef = RefObject<HTMLElement>;
24+
type TriggerRef = RefObject<HTMLElement | null>;
2525

2626
// Have to append ReactNode type to satisfy React's cloneElement function. It
2727
// has absolutely no bearing on what happens at runtime
@@ -62,7 +62,12 @@ type ControlledPopoverProps = BasePopoverProps & {
6262

6363
export type PopoverProps = UncontrolledPopoverProps | ControlledPopoverProps;
6464

65-
export const Popover: FC<PopoverProps> = (props) => {
65+
export const Popover: FC<PopoverProps> = ({
66+
mode,
67+
open,
68+
onOpenChange,
69+
children,
70+
}) => {
6671
const hookId = useId();
6772
const [uncontrolledOpen, setUncontrolledOpen] = useState(false);
6873
const triggerRef: TriggerRef = useRef(null);
@@ -79,15 +84,13 @@ export const Popover: FC<PopoverProps> = (props) => {
7984
const value: PopoverContextValue = {
8085
triggerRef,
8186
id: `${hookId}-popover`,
82-
mode: props.mode ?? "click",
83-
open: props.open ?? uncontrolledOpen,
84-
setOpen: props.onOpenChange ?? setUncontrolledOpen,
87+
mode: mode ?? "click",
88+
open: open ?? uncontrolledOpen,
89+
setOpen: onOpenChange ?? setUncontrolledOpen,
8590
};
8691

8792
return (
88-
<PopoverContext.Provider value={value}>
89-
{props.children}
90-
</PopoverContext.Provider>
93+
<PopoverContext.Provider value={value}>{children}</PopoverContext.Provider>
9194
);
9295
};
9396

@@ -113,10 +116,14 @@ type PopoverTriggerProps = Readonly<
113116
}
114117
>;
115118

116-
export const PopoverTrigger: FC<PopoverTriggerProps> = (props) => {
119+
export const PopoverTrigger: FC<PopoverTriggerProps> = ({
120+
children,
121+
onClick,
122+
onPointerEnter,
123+
onPointerLeave,
124+
...elementProps
125+
}) => {
117126
const popover = usePopover();
118-
const { children, onClick, onPointerEnter, onPointerLeave, ...elementProps } =
119-
props;
120127

121128
const clickProps = {
122129
onClick: (event: PointerEvent<HTMLElement>) => {

site/src/components/Timeline/Timeline.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { TimelineDateRow } from "components/Timeline/TimelineDateRow";
2-
import { Fragment } from "react";
2+
import { Fragment, type JSX } from "react";
33

44
type GetDateFn<TData> = (data: TData) => Date;
55

site/src/hooks/useClickable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export type UseClickableResult<
2323
TElement extends ClickableElement = ClickableElement,
2424
TRole extends ClickableAriaRole = ClickableAriaRole,
2525
> = Readonly<{
26-
ref: RefObject<TElement>;
26+
ref: RefObject<TElement | null>;
2727
tabIndex: 0;
2828
role: TRole;
2929
onClick: MouseEventHandler<TElement>;

site/src/hooks/useClipboard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const useClipboard = (input: UseClipboardInput): UseClipboardResult => {
4444
const { textToCopy, onError: errorCallback } = input;
4545
const [showCopiedSuccess, setShowCopiedSuccess] = useState(false);
4646
const [error, setError] = useState<Error>();
47-
const timeoutIdRef = useRef<number | undefined>();
47+
const timeoutIdRef = useRef<number | undefined>(undefined);
4848

4949
useEffect(() => {
5050
const clearIdOnUnmount = () => window.clearTimeout(timeoutIdRef.current);

site/src/hooks/useWorkspaceBuildLogs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const useWorkspaceBuildLogs = (
99
enabled = true,
1010
) => {
1111
const [logs, setLogs] = useState<ProvisionerJobLog[]>();
12-
const socket = useRef<WebSocket>();
12+
const socket = useRef<WebSocket | undefined>(undefined);
1313

1414
useEffect(() => {
1515
if (!buildId || !enabled) {

site/src/modules/dashboard/Navbar/UserDropdown/UserDropdownContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { CopyButton } from "components/CopyButton/CopyButton";
1919
import { ExternalImage } from "components/ExternalImage/ExternalImage";
2020
import { usePopover } from "components/Popover/Popover";
2121
import { Stack } from "components/Stack/Stack";
22-
import type { FC } from "react";
22+
import type { FC, JSX } from "react";
2323
import { Link } from "react-router-dom";
2424

2525
export const Language = {

site/src/modules/resources/AgentLogs/AgentLogs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Interpolation, Theme } from "@emotion/react";
22
import Tooltip from "@mui/material/Tooltip";
33
import type { WorkspaceAgentLogSource } from "api/typesGenerated";
4-
import { type ComponentProps, forwardRef, useMemo } from "react";
4+
import { type ComponentProps, forwardRef, useMemo, type JSX } from "react";
55
import { FixedSizeList as List } from "react-window";
66
import {
77
AGENT_LOG_LINE_HEIGHT,

site/src/modules/resources/ResourceCard.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Meta, StoryObj } from "@storybook/react";
22
import type { WorkspaceAgent } from "api/typesGenerated";
33
import { ProxyContext, getPreferredProxy } from "contexts/ProxyContext";
4+
import type { JSX } from "react";
45
import {
56
MockProxyLatencies,
67
MockWorkspaceResource,

site/src/modules/resources/ResourceCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { CopyableValue } from "components/CopyableValue/CopyableValue";
66
import { DropdownArrow } from "components/DropdownArrow/DropdownArrow";
77
import { MemoizedInlineMarkdown } from "components/Markdown/Markdown";
88
import { Stack } from "components/Stack/Stack";
9-
import { Children, type FC, useState } from "react";
9+
import { Children, type FC, useState, type JSX } from "react";
1010
import { ResourceAvatar } from "./ResourceAvatar";
1111
import { SensitiveValue } from "./SensitiveValue";
1212

site/src/modules/resources/Resources.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Meta, StoryObj } from "@storybook/react";
22
import type { WorkspaceAgent } from "api/typesGenerated";
33
import { ProxyContext, getPreferredProxy } from "contexts/ProxyContext";
4+
import type { JSX } from "react";
45
import {
56
MockProxyLatencies,
67
MockWorkspaceResource,

site/src/modules/resources/Resources.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Button from "@mui/material/Button";
33
import type { WorkspaceAgent, WorkspaceResource } from "api/typesGenerated";
44
import { DropdownArrow } from "components/DropdownArrow/DropdownArrow";
55
import { Stack } from "components/Stack/Stack";
6-
import { type FC, useState } from "react";
6+
import { type FC, type JSX, useState } from "react";
77
import { ResourceCard } from "./ResourceCard";
88

99
const countAgents = (resource: WorkspaceResource) => {

site/src/modules/templates/TemplateFiles/TemplateFileTree.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ import Menu from "@mui/material/Menu";
66
import MenuItem from "@mui/material/MenuItem";
77
import { SimpleTreeView, TreeItem } from "@mui/x-tree-view";
88
import { DockerIcon } from "components/Icons/DockerIcon";
9-
import { type CSSProperties, type ElementType, type FC, useState } from "react";
9+
import {
10+
type CSSProperties,
11+
type ElementType,
12+
type FC,
13+
type JSX,
14+
useState,
15+
} from "react";
1016
import type { FileTree } from "utils/filetree";
1117

1218
const isFolder = (content?: FileTree | string): content is FileTree =>

site/src/pages/CreateTemplatePage/BuildLogsDrawer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type BuildLogsDrawerProps = {
1919
open: boolean;
2020
onClose: () => void;
2121
templateVersion: TemplateVersion | undefined;
22-
variablesSectionRef: React.RefObject<HTMLDivElement>;
22+
variablesSectionRef: React.RefObject<HTMLDivElement | null>;
2323
};
2424

2525
export const BuildLogsDrawer: FC<BuildLogsDrawerProps> = ({

site/src/pages/CreateTemplatePage/CreateTemplateForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export type CreateTemplateFormProps = (
180180
jobError?: string;
181181
logs?: ProvisionerJobLog[];
182182
allowAdvancedScheduling: boolean;
183-
variablesSectionRef: React.RefObject<HTMLDivElement>;
183+
variablesSectionRef: React.RefObject<HTMLDivElement | null>;
184184
showOrganizationPicker?: boolean;
185185
};
186186

site/src/pages/CreateTemplatePage/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { CreateTemplateOptions } from "api/queries/templates";
33
export type CreateTemplatePageViewProps = {
44
onCreateTemplate: (options: CreateTemplateOptions) => Promise<void>;
55
onOpenBuildLogsDrawer: () => void;
6-
variablesSectionRef: React.RefObject<HTMLDivElement>;
6+
variablesSectionRef: React.RefObject<HTMLDivElement | null>;
77
error: unknown;
88
isCreating: boolean;
99
};

site/src/pages/DeploymentSettingsPage/Fieldset.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { type CSSObject, useTheme } from "@emotion/react";
22
import Button from "@mui/material/Button";
3-
import type { FC, FormEventHandler, ReactNode } from "react";
3+
import type { FC, FormEventHandler, JSX, ReactNode } from "react";
44

55
interface FieldsetProps {
66
children: ReactNode;

site/src/pages/DeploymentSettingsPage/GeneralSettingsPage/ChartSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useTheme } from "@emotion/react";
22
import Paper from "@mui/material/Paper";
3-
import type { FC, HTMLProps, ReactNode } from "react";
3+
import type { FC, HTMLProps, JSX, ReactNode } from "react";
44

55
export interface ChartSectionProps {
66
/**

site/src/pages/DeploymentSettingsPage/UserAuthSettingsPage/UserAuthSettingsPageView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { SerpentOption } from "api/typesGenerated";
22
import { Badges, DisabledBadge, EnabledBadge } from "components/Badges/Badges";
33
import { SettingsHeader } from "components/SettingsHeader/SettingsHeader";
44
import { Stack } from "components/Stack/Stack";
5+
import type { JSX } from "react";
56
import {
67
deploymentGroupHasParent,
78
useDeploymentOptions,

site/src/pages/HealthPage/Content.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export const SectionLabel: FC<HTMLAttributes<HTMLHeadingElement>> = (props) => {
155155
};
156156

157157
type PillProps = HTMLAttributes<HTMLDivElement> & {
158-
icon: ReactElement;
158+
icon: ReactElement<{ className?: string }>;
159159
};
160160

161161
export const Pill = forwardRef<HTMLDivElement, PillProps>((props, ref) => {

site/src/pages/TemplateVersionEditorPage/TemplateVersionEditor.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export const TemplateVersionEditor: FC<TemplateVersionEditorProps> = ({
159159
}, [triggerPreview]);
160160

161161
// Automatically switch to the template preview tab when the build succeeds.
162-
const previousVersion = useRef<TemplateVersion>();
162+
const previousVersion = useRef<TemplateVersion | undefined>(undefined);
163163
useEffect(() => {
164164
if (!previousVersion.current) {
165165
previousVersion.current = templateVersion;
@@ -542,6 +542,7 @@ export const TemplateVersionEditor: FC<TemplateVersionEditorProps> = ({
542542
}}
543543
>
544544
<button
545+
type="button"
545546
disabled={!buildLogs}
546547
css={styles.tab}
547548
className={selectedTab === "logs" ? "active" : ""}
@@ -553,6 +554,7 @@ export const TemplateVersionEditor: FC<TemplateVersionEditorProps> = ({
553554
</button>
554555

555556
<button
557+
type="button"
556558
disabled={!canPublish}
557559
css={styles.tab}
558560
className={selectedTab === "resources" ? "active" : ""}

site/src/pages/TerminalPage/TerminalPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ const TerminalPage: FC = () => {
9999
}, [handleWebLink]);
100100

101101
// Create the terminal!
102-
const fitAddonRef = useRef<FitAddon>();
102+
const fitAddonRef = useRef<FitAddon | undefined>(undefined);
103103
useEffect(() => {
104104
if (!terminalWrapperRef.current || config.isLoading) {
105105
return;

site/src/pages/UsersPage/ResetPasswordDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type * as TypesGen from "api/typesGenerated";
22
import { CodeExample } from "components/CodeExample/CodeExample";
33
import { ConfirmDialog } from "components/Dialogs/ConfirmDialog/ConfirmDialog";
4-
import type { FC } from "react";
4+
import type { FC, JSX } from "react";
55

66
export interface ResetPasswordDialogProps {
77
open: boolean;

site/src/pages/WorkspacePage/WorkspaceScheduleControls.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ const AutostopDisplay: FC<AutostopDisplayProps> = ({
120120
);
121121
const deadlinePlusEnabled = maxDeadlineIncrease >= 1;
122122
const deadlineMinusEnabled = maxDeadlineDecrease >= 1;
123-
const deadlineUpdateTimeout = useRef<number>();
123+
const deadlineUpdateTimeout = useRef<number | undefined>(undefined);
124124
const lastStableDeadline = useRef<Dayjs>(deadline);
125125

126126
const updateWorkspaceDeadlineQueryData = (deadline: Dayjs) => {

0 commit comments

Comments
 (0)