Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 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 deletion .yarn/sdks/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript",
"version": "5.9.3-sdk",
"version": "6.0.2-sdk",
"main": "./lib/typescript.js",
"type": "commonjs",
"bin": {
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/Authentication/SignInForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ function SignInForm(): React.JSX.Element {
autoDismissAfter: 1000 * 60,
});
} catch (e) {
if (!e.message.match(/invalid email or password/i)) {
errorReporting().error(e);
if (!(e instanceof Error && e.message.match(/invalid email or password/i))) {
errorReporting().error(e as string | Error);
}

// we're doing suppressError below specifically so that we can not capture invalid email
Expand Down
1 change: 0 additions & 1 deletion app/javascript/BuiltInFormControls/UserSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ type UserNameLabelProps<OptionType, IsMulti extends boolean> = MultiValueGeneric
name?: string;
};
children: ReactNode;
[x: string]: unknown;
};

function UserNameLabel<OptionType, IsMulti extends boolean>({
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/BuiltInForms/RunFormFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function RunFormFields<RunType extends RunForRunFormFields>({
rooms={convention.rooms ?? []}
isMulti
value={run.rooms}
onChange={(rooms: RoomForSelect[]) => onChange((prevRun) => ({ ...prevRun, rooms }))}
onChange={(rooms) => onChange((prevRun) => ({ ...prevRun, rooms: [...rooms] }))}
/>
)}
</FormGroupWithLabel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ function CmsContentGroupFormFields({
name="contents"
value={contentGroup.contents}
inputId={id}
onChange={(contents: CmsContentOption[]) =>
setContentGroup && setContentGroup({ ...contentGroup, contents })
onChange={(contents) =>
setContentGroup && setContentGroup({ ...contentGroup, contents: [...contents] })
}
isDisabled={disabled || readOnly}
/>
Expand Down Expand Up @@ -122,7 +122,7 @@ function CmsContentGroupFormFields({
options={convention?.staff_positions ?? []}
getOptionValue={(staffPosition) => staffPosition.id.toString()}
getOptionLabel={(staffPosition) => staffPosition.name}
onChange={addRole}
onChange={(role) => role && addRole(role)}
/>
)}
</div>
Expand Down
10 changes: 5 additions & 5 deletions app/javascript/CmsAdmin/NavigationItemsAdmin/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Client implements CadmusNavbarAdminClient {
});
return data!.cmsParent.cmsNavigationItems.map(graphqlNavigationItemToCadmusNavbarAdminObject);
} catch (error) {
this.onError(error);
this.onError(error as Error);
throw error;
} finally {
this.requestsInProgress.loadingNavigationItems = false;
Expand All @@ -105,7 +105,7 @@ class Client implements CadmusNavbarAdminClient {
name: page.name ?? 'Untitled page',
}));
} catch (error) {
this.onError(error);
this.onError(error as Error);
throw error;
} finally {
this.requestsInProgress.loadingPages = false;
Expand Down Expand Up @@ -150,7 +150,7 @@ class Client implements CadmusNavbarAdminClient {
await this.apolloClient.resetStore();
return graphqlNavigationItemToCadmusNavbarAdminObject(mutationResponse.cms_navigation_item);
} catch (error) {
this.onError(error);
this.onError(error as Error);
throw error;
} finally {
this.requestsInProgress.savingNavigationItem = false;
Expand All @@ -168,7 +168,7 @@ class Client implements CadmusNavbarAdminClient {
});
await this.apolloClient.resetStore();
} catch (error) {
this.onError(error);
this.onError(error as Error);
throw error;
} finally {
this.requestsInProgress.deletingNavigationItem = false;
Expand All @@ -193,7 +193,7 @@ class Client implements CadmusNavbarAdminClient {

await this.apolloClient.resetStore();
} catch (error) {
this.onError(error);
this.onError(error as Error);
throw error;
} finally {
this.requestsInProgress.sortingNavigationItems = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function ConventionFormWebsiteSection({
getOptionValue={(option) => option?.id.toString() ?? ''}
getOptionLabel={(option) => option?.name ?? ''}
options={cmsLayouts}
onChange={(newValue: typeof convention.defaultLayout) => setDefaultLayout(newValue)}
onChange={(newValue) => newValue && setDefaultLayout(newValue)}
styles={selectStyles}
isDisabled={disabled}
/>
Expand All @@ -71,7 +71,7 @@ function ConventionFormWebsiteSection({
getOptionValue={(option) => option?.id.toString() ?? ''}
getOptionLabel={(option) => option?.name ?? ''}
options={pages}
onChange={(newValue: typeof convention.rootPage) => setRootPage(newValue)}
onChange={(newValue) => newValue && setRootPage(newValue)}
styles={selectStyles}
isDisabled={disabled}
/>
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/EventAdmin/NewEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function NewEvent() {
encType: 'application/json',
});
} catch (error) {
setCreateError(error);
setCreateError(error instanceof Error ? error : undefined);
throw error;
}
};
Expand Down
10 changes: 3 additions & 7 deletions app/javascript/EventProposals/CreateEventProposalModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function CreateEventProposalModal({
value={department || (eventCategory && eventCategory.department == null ? eventCategory : null)}
getOptionValue={(option) => `${option.__typename}:${option.id}`}
getOptionLabel={(option) => option.name}
onChange={(entity: (typeof topLevelEntities)[0]) => {
onChange={(entity) => {
if (!entity) {
setDepartment(undefined);
setEventCategory(undefined);
Expand Down Expand Up @@ -111,9 +111,7 @@ function CreateEventProposalModal({
value={eventCategory}
getOptionValue={(option) => option.id.toString()}
getOptionLabel={(option) => option.name}
onChange={(category: (typeof departmentEventCategories)[0]) => {
setEventCategory(category);
}}
onChange={(category) => setEventCategory(category ?? undefined)}
/>
</>
)}
Expand Down Expand Up @@ -142,9 +140,7 @@ function CreateEventProposalModal({
value={cloneEventProposal}
getOptionValue={(option) => option.id.toString()}
getOptionLabel={(option) => `${option.title} (${option.event_category.name}, ${option.convention.name})`}
onChange={(proposal: (typeof userEventProposals)[0]) => {
setCloneEventProposal(proposal);
}}
onChange={(proposal) => setCloneEventProposal(proposal ?? undefined)}
/>

{cloneEventProposal &&
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/EventProposals/EventProposalForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function EventProposalFormInner({
setUpdatePromise(promise);
await promise;
} catch (e) {
setUpdateError(e);
setUpdateError(e instanceof Error ? e : undefined);
setResponseErrors(parseResponseErrors(e, ['updateEventProposal']));
} finally {
setUpdatePromise(undefined);
Expand All @@ -102,7 +102,7 @@ function EventProposalFormInner({
setSubmitPromise(promise);
await promise;
} catch (e) {
setSubmitError(e);
setSubmitError(e instanceof Error ? e : undefined);
} finally {
setSubmitPromise(undefined);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function WithdrawMySignupModal({ close, event, run, signup, signupRounds
close();
} catch (error) {
setBusy(false);
setError(error);
setError(error instanceof Error ? error : undefined);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function TimeblockPreferenceEditorTimeblockRow({
try {
getTimeblockTimespanForDisplay(timeblock);
} catch (e) {
return e.message;
return e instanceof Error ? e.message : String(e);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function TimeblockPreferenceEditorTimeblockRowDragOverlay({
try {
getTimeblockTimespanForDisplay(timeblock);
} catch (e) {
return e.message;
return e instanceof Error ? e.message : String(e);
}

return null;
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/NavigationBar/SiteSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ function SiteSearch({ visible, setVisible, visibilityChangeComplete }: SiteSearc
}, [keyDownListener]);

const optionSelected = useCallback(
(entry: SiteSearchOptionType) => {
(entry: SiteSearchOptionType | null) => {
if (!entry) return;
const { model } = entry;
if (model.__typename === 'Page') {
navigate(`/pages/${(model as { slug: string }).slug}`);
Expand Down
6 changes: 4 additions & 2 deletions app/javascript/RootSiteAdmin/EditRootSite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ function EditRootSite() {

useEffect(() => {
if (navigation.state === 'idle' && actionData != null && !error) {
// eslint-disable-next-line react-hooks/set-state-in-effect
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return to this, see if we can eliminate it

setSuccess(true);

setEdited(false);
}
}, [actionData, error, navigation.state]);
Expand All @@ -100,7 +102,7 @@ function EditRootSite() {
getOptionValue={(option) => option.id.toString()}
getOptionLabel={(option) => option.name ?? ''}
options={data.rootSite.cmsLayouts}
onChange={(newValue: (typeof data)['rootSite']['cmsLayouts'][0]) => setDefaultLayout(newValue)}
onChange={(newValue) => newValue && setDefaultLayout(newValue)}
isDisabled={updateInProgress}
/>

Expand All @@ -112,7 +114,7 @@ function EditRootSite() {
getOptionValue={(option) => option.id.toString()}
getOptionLabel={(option) => option.name ?? ''}
options={data.rootSite.cmsPages}
onChange={(newValue: (typeof data)['rootSite']['rootPage']) => setRootPage(newValue)}
onChange={(newValue) => newValue && setRootPage(newValue)}
isDisabled={updateInProgress}
/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export default function NewConventionModal({ data, cloneConvention }: NewConvent
label="Initial CMS content set"
options={CMS_CONTENT_SET_OPTIONS}
value={cmsContentSet}
onChange={(newValue: (typeof CMS_CONTENT_SET_OPTIONS)[0]) => setCmsContentSet(newValue)}
onChange={(newValue) => setCmsContentSet(newValue)}
getOptionLabel={(option) => option.label}
getOptionValue={(option) => option.name}
/>
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/SignupModeration/CreateSignup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function CreateSignup(): React.JSX.Element {
<EventSelect
id={id}
value={event}
onChange={(newEvent: EventType) => setEvent(newEvent)}
onChange={(newEvent) => setEvent(newEvent ?? undefined)}
eventsQuery={CreateSignupEventsQueryDocument}
/>
)}
Expand All @@ -43,7 +43,7 @@ function CreateSignup(): React.JSX.Element {
<UserConProfileSelect
id={id}
value={userConProfile}
onChange={(newUserConProfile: UserConProfileType) => setUserConProfile(newUserConProfile)}
onChange={(newUserConProfile) => setUserConProfile(newUserConProfile ?? undefined)}
/>
)}
</FormGroupWithLabel>
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/SignupModeration/RankedChoiceQueue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function RankedChoiceQueue() {
<UserConProfileSelect
id={id}
value={userConProfile}
onChange={(newUserConProfile: UserConProfileType) => setUserConProfile(newUserConProfile)}
onChange={(newUserConProfile) => setUserConProfile(newUserConProfile ?? undefined)}
/>
)}
</FormGroupWithLabel>
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/Store/OrderAdmin/AdminOrderEntriesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ function AdminOrderEntriesTable<
<Select
options={addingItem.product?.product_variants ?? []}
value={addingItem.product_variant}
onChange={setAddingItemProductVariant}
onChange={(variant) => setAddingItemProductVariant(variant ?? null)}
getOptionValue={(variant) => variant?.id?.toString() ?? ''}
getOptionLabel={(variant) => variant?.name ?? ''}
isClearable
Expand Down
5 changes: 3 additions & 2 deletions app/javascript/Store/OrderPaymentModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function OrderPaymentModalContents({ onCancel, onComplete, onError, order
await submit({ totalPrice, paymentMode, orderId: order.id, submitOrder });
onComplete();
} catch (error) {
onError(error);
onError(error as Error);
}
},
{ suppressError: true },
Expand Down Expand Up @@ -173,11 +173,12 @@ function OrderPaymentModal({
result.data?.convention.my_profile?.current_pending_order?.payment_intent_client_secret,
);
} catch (error) {
onErrorRef.current(error);
onErrorRef.current(error as Error);
}
}, [client]);

useEffect(() => {
// eslint-disable-next-line react-hooks/set-state-in-effect
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revisit this to see if we can remove it

setPaymentIntentClientSecret(undefined);

if (paymentIntentClientSecretNeeded) {
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/UserConProfiles/AddAttendeeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ function AddAttendeeModal(): React.JSX.Element {
navigate('/user_con_profiles', { replace: true });
};

const userSelected = (newUser: UserType) => {
const userSelected = (newUser: UserType | null) => {
if (!newUser) return;
setUser(newUser);
setUserConProfile({
__typename: 'UserConProfile',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,11 @@ function ConvertToEventProvidedTicketModal({

<EventSelect
value={event}
onChange={(value: DefaultEventSelectOptionType) => {
setEvent(value);
setTicketTypeId(undefined);
onChange={(value) => {
if (value) {
setEvent(value);
setTicketTypeId(undefined);
}
}}
isDisabled={inProgress}
/>
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/parseResponseErrors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class FormValidationError extends Error {
}
}

export function parseResponseErrors(error: Error, errorPath: readonly (string | number)[]) {
export function parseResponseErrors(error: unknown, errorPath: readonly (string | number)[]) {
if (CombinedGraphQLErrors.is(error)) {
const updateError = error.errors.find((graphQLError) => isEqual(graphQLError.path, errorPath));
const validationErrors = (updateError?.extensions?.validationErrors as Record<string, string[]>) ?? {};
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/useAsyncFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function useAsyncFunction<T, A extends unknown[]>(
return await func(...args);
} catch (e) {
if (isMounted.current) {
setError(e);
setError(e as Error);
}
if (!suppressError) {
throw e;
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@
"@types/qs": "^6",
"@types/rails__activestorage": "8.0.1",
"@types/react-dom": "19.2.3",
"@typescript-eslint/eslint-plugin": "8.46.4",
"@typescript-eslint/parser": "8.46.4",
"@typescript-eslint/utils": "^8.36.0",
"@typescript-eslint/eslint-plugin": "8.58.0",
"@typescript-eslint/parser": "8.58.0",
"@typescript-eslint/utils": "^8.58.0",
"@vitejs/plugin-react-swc": "^4.2.0",
"@vitest/coverage-v8": "^4.0.0",
"@vitest/eslint-plugin": "^1.1.24",
Expand Down Expand Up @@ -223,8 +223,8 @@
"tslib": "^2.8.1",
"tsx": "^4.20.3",
"typed-scss-modules": "^8.1.1",
"typescript": "5.9.3",
"typescript-eslint": "^8.36.0",
"typescript": "6.0.2",
"typescript-eslint": "^8.58.0",
"vite": "^7.0.0",
"vite-bundle-visualizer": "^1.2.1",
"vite-plugin-node-polyfills": "^0.24.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('ConventionDaySelect', () => {

test('it renders an option for each convention day', async () => {
const { getAllByRole } = await renderConventionDaySelect();
expect(getAllByRole('radio').map((input: HTMLInputElement) => input.value)).toEqual([
expect(getAllByRole('radio').map((input: HTMLElement) => (input as HTMLInputElement).value)).toEqual([
'2017-01-01T00:00:00.000+00:00',
'2017-01-02T06:00:00.000+00:00',
'2017-01-03T06:00:00.000+00:00',
Expand Down
Loading