Skip to content

Commit e01f33c

Browse files
authored
Merge pull request #4264 from github/copilot/fix-github-actions-workflow-lint-again
Fix TypeScript type errors in VSCode Elements event handlers and refs
2 parents ad70ecd + 42b1cb7 commit e01f33c

File tree

11 files changed

+50
-53
lines changed

11 files changed

+50
-53
lines changed

extensions/ql-vscode/src/view/common/CodePaths/CodeFlowsDropdown.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ChangeEvent, SetStateAction } from "react";
1+
import type { SetStateAction } from "react";
22
import { useCallback } from "react";
33
import {
44
VscodeOption,
@@ -25,8 +25,8 @@ export const CodeFlowsDropdown = ({
2525
setSelectedCodeFlow,
2626
}: CodeFlowsDropdownProps) => {
2727
const handleChange = useCallback(
28-
(e: ChangeEvent<HTMLSelectElement>) => {
29-
const selectedOption = e.target;
28+
(e: Event) => {
29+
const selectedOption = e.target as HTMLSelectElement;
3030
const selectedIndex = parseInt(selectedOption.value);
3131
setSelectedCodeFlow(codeFlows[selectedIndex]);
3232
},

extensions/ql-vscode/src/view/common/DataGrid.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const DataGridRow = forwardRef(
8383
"data-testid": testId,
8484
onClick,
8585
}: DataGridRowProps,
86-
ref?: React.Ref<HTMLElement | undefined>,
86+
ref?: React.Ref<HTMLDivElement>,
8787
) => (
8888
<StyledDataGridRow
8989
$focused={focused}
@@ -135,7 +135,7 @@ export const DataGridCell = forwardRef(
135135
className,
136136
children,
137137
}: DataGridCellProps,
138-
ref?: React.Ref<HTMLElement | undefined>,
138+
ref?: React.Ref<HTMLDivElement>,
139139
) => {
140140
return (
141141
<StyledDataGridCell

extensions/ql-vscode/src/view/common/TextButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { styled } from "styled-components";
22

33
type Size = "x-small" | "small" | "medium" | "large" | "x-large";
44

5-
const StyledButton = styled.button<{ $size: Size }>`
5+
const StyledButton = styled.button<{ $size?: Size }>`
66
background: none;
77
color: var(--vscode-textLink-foreground);
88
border: none;

extensions/ql-vscode/src/view/model-alerts/ModelAlertsSort.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type Props = {
2020

2121
export const ModelAlertsSort = ({ value, onChange, className }: Props) => {
2222
const handleInput = useCallback(
23-
(e: InputEvent) => {
23+
(e: Event) => {
2424
const target = e.target as HTMLSelectElement;
2525

2626
onChange(target.value as SortKey);

extensions/ql-vscode/src/view/model-editor/MethodRow.tsx

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export type MethodRowProps = {
8585
export const MethodRow = (props: MethodRowProps) => {
8686
const { method, methodCanBeModeled, revealedMethodSignature } = props;
8787

88-
const ref = useRef<HTMLElement | undefined>(undefined);
88+
const ref = useRef<HTMLDivElement>(null);
8989

9090
useEffect(() => {
9191
if (method.signature === revealedMethodSignature) {
@@ -103,7 +103,7 @@ export const MethodRow = (props: MethodRowProps) => {
103103
}
104104
};
105105

106-
const ModelableMethodRow = forwardRef<HTMLElement | undefined, MethodRowProps>(
106+
const ModelableMethodRow = forwardRef<HTMLDivElement, MethodRowProps>(
107107
(props: MethodRowProps, ref) => {
108108
const {
109109
method,
@@ -359,39 +359,38 @@ const ModelableMethodRow = forwardRef<HTMLElement | undefined, MethodRowProps>(
359359
);
360360
ModelableMethodRow.displayName = "ModelableMethodRow";
361361

362-
const UnmodelableMethodRow = forwardRef<
363-
HTMLElement | undefined,
364-
MethodRowProps
365-
>((props: MethodRowProps, ref) => {
366-
const { method, viewState, revealedMethodSignature } = props;
367-
368-
const jumpToMethod = useCallback(
369-
() => sendJumpToMethodMessage(method),
370-
[method],
371-
);
372-
373-
return (
374-
<DataGridRow
375-
data-testid="unmodelable-method-row"
376-
focused={revealedMethodSignature === method.signature}
377-
>
378-
<DataGridCell ref={ref}>
379-
<ApiOrMethodRow>
380-
<ModelingStatusIndicator status="saved" />
381-
<MethodClassifications method={method} />
382-
<MethodName {...props.method} />
383-
{viewState.mode === Mode.Application && (
384-
<UsagesButton onClick={jumpToMethod}>
385-
{method.usages.length}
386-
</UsagesButton>
387-
)}
388-
<ViewLink onClick={jumpToMethod}>View</ViewLink>
389-
</ApiOrMethodRow>
390-
</DataGridCell>
391-
<DataGridCell gridColumn="span 5">Method already modeled</DataGridCell>
392-
</DataGridRow>
393-
);
394-
});
362+
const UnmodelableMethodRow = forwardRef<HTMLDivElement, MethodRowProps>(
363+
(props: MethodRowProps, ref) => {
364+
const { method, viewState, revealedMethodSignature } = props;
365+
366+
const jumpToMethod = useCallback(
367+
() => sendJumpToMethodMessage(method),
368+
[method],
369+
);
370+
371+
return (
372+
<DataGridRow
373+
data-testid="unmodelable-method-row"
374+
focused={revealedMethodSignature === method.signature}
375+
>
376+
<DataGridCell ref={ref}>
377+
<ApiOrMethodRow>
378+
<ModelingStatusIndicator status="saved" />
379+
<MethodClassifications method={method} />
380+
<MethodName {...props.method} />
381+
{viewState.mode === Mode.Application && (
382+
<UsagesButton onClick={jumpToMethod}>
383+
{method.usages.length}
384+
</UsagesButton>
385+
)}
386+
<ViewLink onClick={jumpToMethod}>View</ViewLink>
387+
</ApiOrMethodRow>
388+
</DataGridCell>
389+
<DataGridCell gridColumn="span 5">Method already modeled</DataGridCell>
390+
</DataGridRow>
391+
);
392+
},
393+
);
395394
UnmodelableMethodRow.displayName = "UnmodelableMethodRow";
396395

397396
function sendJumpToMethodMessage(method: Method) {

extensions/ql-vscode/src/view/model-editor/ModelTypeTextbox.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { ChangeEvent } from "react";
21
import { useCallback, useEffect, useState } from "react";
32
import type {
43
ModeledMethod,
@@ -33,8 +32,8 @@ export const ModelTypeTextbox = ({
3332
setValue(modeledMethod[typeInfo]);
3433
}, [modeledMethod, typeInfo]);
3534

36-
const handleChange = useCallback((e: ChangeEvent<HTMLSelectElement>) => {
37-
const target = e.target as HTMLSelectElement;
35+
const handleChange = useCallback((e: Event) => {
36+
const target = e.target as HTMLInputElement;
3837

3938
setValue(target.value);
4039
}, []);

extensions/ql-vscode/src/view/variant-analysis/RepoRow.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { ChangeEvent } from "react";
21
import { useCallback, useEffect, useState } from "react";
32
import { styled } from "styled-components";
43
import { VscodeCheckbox } from "@vscode-elements/react-elements";
@@ -229,17 +228,18 @@ export const RepoRow = ({
229228
e.stopPropagation();
230229
}, []);
231230
const onChangeCheckbox = useCallback(
232-
(e: ChangeEvent<HTMLInputElement>) => {
231+
(e: Event) => {
232+
const target = e.target as HTMLInputElement;
233233
// This is called on first render, but we don't really care about this value
234-
if (e.target.checked === undefined) {
234+
if (target.checked === undefined) {
235235
return;
236236
}
237237

238238
if (!repository.id) {
239239
return;
240240
}
241241

242-
onSelectedChange?.(repository.id, e.target.checked);
242+
onSelectedChange?.(repository.id, target.checked);
243243
},
244244
[onSelectedChange, repository],
245245
);

extensions/ql-vscode/src/view/variant-analysis/RepositoriesFilter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type Props = {
2020

2121
export const RepositoriesFilter = ({ value, onChange, className }: Props) => {
2222
const handleInput = useCallback(
23-
(e: InputEvent) => {
23+
(e: Event) => {
2424
const target = e.target as HTMLSelectElement;
2525

2626
onChange(target.value as FilterKey);

extensions/ql-vscode/src/view/variant-analysis/RepositoriesResultFormat.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const RepositoriesResultFormat = ({
2424
className,
2525
}: Props) => {
2626
const handleInput = useCallback(
27-
(e: InputEvent) => {
27+
(e: Event) => {
2828
const target = e.target as HTMLSelectElement;
2929

3030
onChange(target.value as ResultFormat);

extensions/ql-vscode/src/view/variant-analysis/RepositoriesSort.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type Props = {
2020

2121
export const RepositoriesSort = ({ value, onChange, className }: Props) => {
2222
const handleInput = useCallback(
23-
(e: InputEvent) => {
23+
(e: Event) => {
2424
const target = e.target as HTMLSelectElement;
2525

2626
onChange(target.value as SortKey);

0 commit comments

Comments
 (0)