Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore(site): enable noUncheckedIndexedAccess TypeScript option#21383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
mtojek wants to merge1 commit intomain
base:main
Choose a base branch
Loading
fromenable-no-unchecked-indexed-access
Draft
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletionsite/e2e/api.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@ export const getCurrentOrgId = async (): Promise<string> => {
return currentOrgId;
}
const currentUser = await API.getAuthenticatedUser();
currentOrgId = currentUser.organization_ids[0];
currentOrgId = currentUser.organization_ids[0]!;
return currentOrgId;
};

Expand Down
4 changes: 2 additions & 2 deletionssite/e2e/tests/users/userSettings.spec.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,12 +17,12 @@ test("adjust user theme preference", async ({ page }) => {

// Make sure the page is actually updated to use the light theme
const [root] = await page.$$("html");
expect(await root.evaluate((it) => it.className)).toContain("light");
expect(await root!.evaluate((it) => it.className)).toContain("light");

await page.goto("/", { waitUntil: "domcontentloaded" });

// Make sure the page is still using the light theme after reloading and
// navigating away from the settings page.
const [homeRoot] = await page.$$("html");
expect(await homeRoot.evaluate((it) => it.className)).toContain("light");
expect(await homeRoot!.evaluate((it) => it.className)).toContain("light");
});
4 changes: 2 additions & 2 deletionssite/e2e/tests/workspaces/createWorkspace.spec.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -119,8 +119,8 @@ test("create workspace and overwrite default parameters", async ({ page }) => {
];

const buildParameters = [
{ name: richParameters[0].name, value: "AAAAA" },
{ name: richParameters[1].name, value: "false" },
{ name: richParameters[0]!.name, value: "AAAAA" },
{ name: richParameters[1]!.name, value: "false" },
];
const template = await createTemplate(
page,
Expand Down
12 changes: 6 additions & 6 deletionssite/e2e/tests/workspaces/startWorkspace.spec.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,17 +30,17 @@ test("start workspace with ephemeral parameters", async ({ page }) => {

// Verify that build options are default (not selected).
await verifyParameters(page, workspaceName, richParameters, [
{ name: richParameters[0].name, value: firstBuildOption.defaultValue },
{ name: richParameters[1].name, value: secondBuildOption.defaultValue },
{ name: richParameters[0]!.name, value: firstBuildOption.defaultValue },
{ name: richParameters[1]!.name, value: secondBuildOption.defaultValue },
]);

// Stop the workspace
await stopWorkspace(page, workspaceName);

// Now, start the workspace with ephemeral parameters selected.
const buildParameters = [
{ name: richParameters[0].name, value: "AAAAA" },
{ name: richParameters[1].name, value: "true" },
{ name: richParameters[0]!.name, value: "AAAAA" },
{ name: richParameters[1]!.name, value: "true" },
];

await startWorkspaceWithEphemeralParameters(
Expand All@@ -55,7 +55,7 @@ test("start workspace with ephemeral parameters", async ({ page }) => {

// Verify that build options are default (not selected).
await verifyParameters(page, workspaceName, richParameters, [
{ name: richParameters[0].name, value: firstBuildOption.defaultValue },
{ name: richParameters[1].name, value: secondBuildOption.defaultValue },
{ name: richParameters[0]!.name, value: firstBuildOption.defaultValue },
{ name: richParameters[1]!.name, value: secondBuildOption.defaultValue },
]);
});
4 changes: 2 additions & 2 deletionssite/e2e/tests/workspaces/updateWorkspace.spec.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,14 +62,14 @@ test.skip("update workspace, new optional, immutable parameter added", async ({
// Now, update the workspace, and select the value for immutable parameter.
await login(page, users.member);
await updateWorkspace(page, workspaceName, updatedRichParameters, [
{ name: fifthParameter.name, value: fifthParameter.options[0].value },
{ name: fifthParameter.name, value: fifthParameter.options[0]!.value },
]);

// Verify parameter values.
await verifyParameters(page, workspaceName, updatedRichParameters, [
{ name: firstParameter.name, value: firstParameter.defaultValue },
{ name: secondParameter.name, value: secondParameter.defaultValue },
{ name: fifthParameter.name, value: fifthParameter.options[0].value },
{ name: fifthParameter.name, value: fifthParameter.options[0]!.value },
]);
});

Expand Down
4 changes: 2 additions & 2 deletionssite/src/api/queries/notifications.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -83,14 +83,14 @@ export function selectTemplatesByGroup(
if (!grouped[template.group]) {
grouped[template.group] = [];
}
grouped[template.group].push(template);
grouped[template.group]!.push(template);
}

// Sort groups by name, and sort templates within each group
const sortedGroups = Object.keys(grouped).sort((a, b) => a.localeCompare(b));
const sortedGrouped: Record<string, NotificationTemplate[]> = {};
for (const group of sortedGroups) {
sortedGrouped[group] = grouped[group].sort((a, b) =>
sortedGrouped[group] = grouped[group]!.sort((a, b) =>
a.name.localeCompare(b.name),
);
}
Expand Down
2 changes: 1 addition & 1 deletionsite/src/api/queries/workspaces.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -187,7 +187,7 @@ async function findMatchWorkspace(q: string): Promise<Workspace | undefined> {
} catch (err) {
if (isApiValidationError(err)) {
const firstValidationErrorDetail =
err.response.data.validations?.[0].detail;
err.response.data.validations?.[0]?.detail;
throw new DetailedError(
"Invalid match value",
firstValidationErrorDetail,
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,7 +66,7 @@ export const ActiveUserChart: FC<ActiveUserChartProps> = ({ data }) => {
labelClassName="text-content-primary"
labelFormatter={(_, p) => {
const item = p[0];
return `${item.value} active users`;
return `${item?.value} active users`;
}}
formatter={(_v, _n, item) => {
const date = new Date(item.payload.date);
Expand Down
10 changes: 5 additions & 5 deletionssite/src/components/Autocomplete/Autocomplete.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,7 +62,7 @@ export const Default: Story = {

export const WithSelectedValue: Story = {
render: function WithSelectedValueStory() {
const [value, setValue] = useState<SimpleOption | null>(simpleOptions[2]);
const [value, setValue] = useState<SimpleOption | null>(simpleOptions[2]!);
return (
<div className="w-80">
<Autocomplete
Expand DownExpand Up@@ -96,7 +96,7 @@ export const WithSelectedValue: Story = {

export const NotClearable: Story = {
render: function NotClearableStory() {
const [value, setValue] = useState<SimpleOption | null>(simpleOptions[0]);
const [value, setValue] = useState<SimpleOption | null>(simpleOptions[0]!);
return (
<div className="w-80">
<Autocomplete
Expand DownExpand Up@@ -142,7 +142,7 @@ export const Loading: Story = {

export const Disabled: Story = {
render: function DisabledStory() {
const [value, setValue] = useState<SimpleOption | null>(simpleOptions[1]);
const [value, setValue] = useState<SimpleOption | null>(simpleOptions[1]!);
return (
<div className="w-80">
<Autocomplete
Expand DownExpand Up@@ -223,7 +223,7 @@ export const SearchAndFilter: Story = {

export const ClearSelection: Story = {
render: function ClearSelectionStory() {
const [value, setValue] = useState<SimpleOption | null>(simpleOptions[0]);
const [value, setValue] = useState<SimpleOption | null>(simpleOptions[0]!);
return (
<div className="w-80">
<Autocomplete
Expand DownExpand Up@@ -318,7 +318,7 @@ export const WithCustomRenderOption: Story = {

export const WithStartAdornment: Story = {
render: function WithStartAdornmentStory() {
const [value, setValue] = useState<User | null>(users[0]);
const [value, setValue] = useState<User | null>(users[0]!);
return (
<div className="w-[350px]">
<Autocomplete
Expand Down
2 changes: 1 addition & 1 deletionsite/src/components/Chart/Chart.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,7 +154,7 @@ export const ChartTooltipContent = React.forwardRef<
}

const [item] = payload;
const key = `${labelKey || item.dataKey || item.name || "value"}`;
const key = `${labelKey || item?.dataKey || item?.name || "value"}`;
const itemConfig = getPayloadConfigFromPayload(config, item, key);
const value =
!labelKey && typeof label === "string"
Expand Down
2 changes: 1 addition & 1 deletionsite/src/components/Conditionals/ChooseOne.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,7 +35,7 @@ export const ChooseOne: FC<PropsWithChildren> = ({ children }) => {
return null;
}
const conditionedOptions = childArray.slice(0, childArray.length - 1);
const defaultCase = childArray[childArray.length - 1];
const defaultCase = childArray[childArray.length - 1]!;
if (defaultCase.props.condition !== undefined) {
throw new Error(
"The last Cond in a ChooseOne was given a condition prop, but it is the default case.",
Expand Down
2 changes: 1 addition & 1 deletionsite/src/components/GlobalSnackbar/utils.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -64,7 +64,7 @@ describe("Snackbar", () => {
// calls[0][0] is the first argument of the first call
// calls[0][0].detail is the 'detail' argument passed to the `CustomEvent` -
// this is the `NotificationMsg` object that gets sent to `dispatchEvent`
return dispatchEventMock.mock.calls[0][0].detail;
return dispatchEventMock.mock.calls[0]![0]!.detail;
};

beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletionsite/src/components/IconField/EmojiPicker.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@ const custom = [
id: "icons",
name: "Icons",
emojis: icons.map((icon) => {
const id = icon.split(".")[0];
const id = icon.split(".")[0]!;

return {
id,
Expand Down
4 changes: 2 additions & 2 deletionssite/src/components/Markdown/Markdown.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,7 +63,7 @@ export const Markdown: FC<MarkdownProps> = (props) => {
const firstChild = node.children[0];
// When pre is wrapping a code, the SyntaxHighlighter is already going
// to wrap it with a pre so we don't need it
if (firstChild.type === "element" && firstChild.tagName === "code") {
if (firstChild && firstChild.type === "element" && firstChild.tagName === "code") {
return <>{children}</>;
}
return <pre>{children}</pre>;
Expand All@@ -75,7 +75,7 @@ export const Markdown: FC<MarkdownProps> = (props) => {
return match ? (
<SyntaxHighlighter
style={dracula}
language={match[1].toLowerCase() ?? "language-shell"}
language={match[1]!.toLowerCase() ?? "language-shell"}
useInlineStyles={false}
codeTagProps={{ style: {} }}
{...restProps} // Exclude 'ref' from being passed here
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -95,7 +95,7 @@ export const ClearFirstSelectedItem: Story = {
await userEvent.click(
canvas.getByRole("option", { name: "My Organization 2" }),
);
await userEvent.click(canvas.getAllByTestId("clear-option-button")[0]);
await userEvent.click(canvas.getAllByTestId("clear-option-button")[0]!);
},
};

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -257,10 +257,10 @@ export const MultiSelectCombobox = forwardRef<
if (input) {
if (e.key === "Delete" || e.key === "Backspace") {
if (input.value === "" && selected.length > 0) {
const lastSelectOption = selected[selected.length - 1];
const lastSelectOption = selected[selected.length - 1]!;
// If last item is fixed, we should not remove it.
if (!lastSelectOption.fixed) {
handleUnselect(selected[selected.length - 1]);
handleUnselect(selected[selected.length - 1]!);
}
}
}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -64,7 +64,7 @@ export const OrganizationAutocomplete: FC<OrganizationAutocompleteProps> = ({
// its own data. Until we refactor, proceed cautiously!
useEffect(() => {
const org = options[0];
if (options.length !== 1 || org === selected) {
if (options.length !== 1 || org === selected || !org) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletionsite/src/components/Slider/Slider.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,7 +32,7 @@ export const Controlled: Story = {
render: (args) => {
const [value, setValue] = React.useState(50);
return (
<Slider {...args} value={[value]} onValueChange={([v]) => setValue(v)} />
<Slider {...args} value={[value]} onValueChange={([v]) => setValue(v!)} />
);
},
args: { value: [50], min: 0, max: 100, step: 1 },
Expand Down
2 changes: 1 addition & 1 deletionsite/src/components/TagInput/TagInput.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -61,7 +61,7 @@ export const TagInput: FC<TagInputProps> = ({
return;
}

const lastValue = values[values.length - 1];
const lastValue = values[values.length - 1]!;
onChange(values.slice(0, -1));
event.currentTarget.value = lastValue;
}
Expand Down
4 changes: 2 additions & 2 deletionssite/src/components/Timeline/Timeline.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,9 +13,9 @@ const groupByDate = <TData,>(
const dateKey = getDate(item).toDateString();

if (dateKey in itemsByDate) {
itemsByDate[dateKey].push(item);
itemsByDate[dateKey]!.push(item);
} else {
itemsByDate[dateKey] = [item];
itemsByDate[dateKey]! = [item];
}
}

Expand Down
4 changes: 2 additions & 2 deletionssite/src/contexts/useProxyLatency.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -111,10 +111,10 @@ export const useProxyLatency = (
// 2. If the latest latency is after the latestFetchRequest, then skip the latency check.
if (
storedLatencies?.[proxy.id] &&
storedLatencies[proxy.id].length > 0
storedLatencies[proxy.id]!.length > 0
) {
const fetchRequestDate = new Date(latestFetchRequest);
const latest = storedLatencies[proxy.id].reduce((prev, next) =>
const latest = storedLatencies[proxy.id]!.reduce((prev, next) =>
prev.at > next.at ? prev : next,
);

Expand Down
4 changes: 2 additions & 2 deletionssite/src/contexts/useWebpushNotifications.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -69,8 +69,8 @@ export const useWebpushNotifications = (): WebpushNotifications => {

await API.createWebPushSubscription("me", {
endpoint: json.endpoint,
auth_key: json.keys.auth,
p256dh_key: json.keys.p256dh,
auth_key: json.keys!.auth!,
p256dh_key: json.keys!.p256dh!,
});

setSubscribed(true);
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,14 +67,14 @@ export const LicenseBannerView: FC<LicenseBannerViewProps> = ({
<div css={containerStyles}>
<Pill type={type}>{Language.licenseIssue}</Pill>
<div css={styles.leftContent}>
<span>{formatMessage(messages[0])}</span>
<span>{formatMessage(messages[0]!)}</span>
&nbsp;
<Link
color={textColor}
fontWeight="medium"
href="mailto:sales@coder.com"
>
{messages[0] === LicenseTelemetryRequiredErrorText
{messages[0]! === LicenseTelemetryRequiredErrorText
? Language.exception
: Language.upgrade}
</Link>
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -69,7 +69,7 @@ export const SingleProxy: Story = {
args: {
proxyContextValue: {
...defaultProxyContextValue,
proxies: [MockWorkspaceProxies[0]],
proxies: [MockWorkspaceProxies[0]!],
},
},
play: async ({ canvasElement }) => {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -101,13 +101,13 @@ export const OnMarkNotificationAsRead: Story = {
play: async ({ canvasElement, args }) => {
const body = within(canvasElement.ownerDocument.body);
const notifications = body.getAllByRole("menuitem");
const secondNotification = notifications[1];
const secondNotification = notifications[1]!;
await userEvent.click(secondNotification);
const markButton = body.getByRole("button", { name: /mark as read/i });
await userEvent.click(markButton);
await expect(args.onMarkNotificationAsRead).toHaveBeenCalledTimes(1);
await expect(args.onMarkNotificationAsRead).toHaveBeenCalledWith(
args.notifications?.[1].id,
args.notifications?.[1]!.id,
);
},
parameters: {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -139,15 +139,15 @@ export const MarkNotificationAsRead: Story = {
markNotificationAsRead: fn(async () => ({
unread_count: 1,
notification: {
...MockNotifications[1],
...MockNotifications[1]!,
read_at: new Date().toISOString(),
},
})),
},
play: async ({ canvasElement }) => {
const body = within(canvasElement.ownerDocument.body);
const notifications = await body.findAllByRole("menuitem");
const secondNotification = notifications[1];
const secondNotification = notifications[1]!;
within(secondNotification).getByText(/unread/i);

await userEvent.click(secondNotification);
Expand All@@ -172,7 +172,7 @@ export const MarkNotificationAsReadFailure: Story = {
play: async ({ canvasElement }) => {
const body = within(canvasElement.ownerDocument.body);
const notifications = await body.findAllByRole("menuitem");
const secondNotification = notifications[1];
const secondNotification = notifications[1]!;
await userEvent.click(secondNotification);
const markButton = body.getByRole("button", { name: /mark as read/i });
await userEvent.click(markButton);
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -98,7 +98,7 @@ export const NotificationsInbox: FC<NotificationsInboxProps> = ({
}
const lastNotification =
inboxRes.notifications[inboxRes.notifications.length - 1];
const newRes = await fetchNotifications(lastNotification.id);
const newRes = await fetchNotifications(lastNotification!.id);
updateNotificationsCache((prev) => {
return {
unread_count: newRes.unread_count,
Expand Down
4 changes: 2 additions & 2 deletionssite/src/modules/provisioners/ProvisionerTags.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,8 +39,8 @@ export const ProvisionerTruncateTags: FC<ProvisionerTagsProps> = ({ tags }) => {
return null;
}

const firstKey = keys[0];
const firstValue = tags[firstKey];
const firstKey = keys[0]!;
const firstValue = tags[firstKey]!;
const remainderCount = keys.length - 1;

return (
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp