Skip to content

Commit

Permalink
[Fix] Fix consistent types for useRequiredParams (#11663)
Browse files Browse the repository at this point in the history
* adjust required params type signature

* narrow type
  • Loading branch information
esizer authored Oct 2, 2024
1 parent 994bcf0 commit 0e9824a
Show file tree
Hide file tree
Showing 33 changed files with 67 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ export const getPageInfo: GetPageNavInfo = ({
};
};

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
experienceId: string;
applicationId: string;
};
}

interface ApplicationCareerTimelineEditProps extends ApplicationPageProps {
experience: AnyExperience;
Expand Down
5 changes: 2 additions & 3 deletions apps/web/src/pages/Applications/ApplicationLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ import { ContextType } from "./useApplication";
import Application_PoolCandidateFragment from "./fragment";
import { getApplicationSteps } from "./utils";

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
experienceId: string;
};
}

interface ApplicationPageWrapperProps {
query: FragmentType<typeof Application_PoolCandidateFragment>;
Expand Down
5 changes: 2 additions & 3 deletions apps/web/src/pages/Applications/useApplicationId.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import useRequiredParams from "~/hooks/useRequiredParams";

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
applicationId: string;
};
}

const useApplicationId = () => {
const { applicationId } = useRequiredParams<RouteParams>("applicationId");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,9 @@ export const UpdateClassificationForm = ({
);
};

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
classificationId: Scalars["ID"]["output"];
};
}

const Classification_Query = graphql(/* GraphQL */ `
query Classification($id: UUID!) {
Expand Down
5 changes: 2 additions & 3 deletions apps/web/src/pages/Communities/CommunityLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,9 @@ const CommunityLayoutCommunityName_Query = graphql(/* GraphQL */ `
}
`);

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
communityId: string;
};
}

const CommunityLayout = () => {
const { communityId } = useRequiredParams<RouteParams>("communityId");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,9 @@ const CommunityMembersTeam_Query = graphql(/* GraphQL */ `
}
`);

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
communityId: Scalars["ID"]["output"];
};
}

const CommunityMembersPage = () => {
const { communityId } = useRequiredParams<RouteParams>("communityId");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ import RequireAuth from "~/components/RequireAuth/RequireAuth";

import CommunitySection from "./components/CommunitySection";

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
communityId: Scalars["ID"]["output"];
};
}

const ViewCommunity_Query = graphql(/* GraphQL */ `
query ViewCommunity($id: UUID!) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ import useRoutes from "~/hooks/useRoutes";
import useRequiredParams from "~/hooks/useRequiredParams";
import RequireAuth from "~/components/RequireAuth/RequireAuth";

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
poolId: Scalars["ID"]["output"];
};
}

const CreateApplicationApplications_Query = graphql(/* GraphQL */ `
query CreateApplicationApplications {
Expand Down
5 changes: 2 additions & 3 deletions apps/web/src/pages/Departments/UpdateDepartmentPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,9 @@ export const UpdateDepartmentForm = ({
);
};

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
departmentId: Scalars["ID"]["output"];
};
}

const Department_Query = graphql(/* GraphQL */ `
query Department($id: UUID!) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,9 @@ const JobPosterTemplatePage_Query = graphql(/* GraphQL */ `
}
`);

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
templateId: Scalars["ID"]["output"];
};
}

const context: Partial<OperationContext> = {
requestPolicy: "cache-first",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ import adminMessages from "~/messages/adminMessages";
import useRequiredParams from "~/hooks/useRequiredParams";
import RequireAuth from "~/components/RequireAuth/RequireAuth";

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
poolId: Scalars["ID"]["output"];
};
}

const IndexPoolCandidatePage_Query = graphql(/* GraphQL */ `
query IndexPoolCandidatePage($id: UUID!) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,10 @@ const context: Partial<OperationContext> = {
additionalTypenames: ["AssessmentResult"],
};

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
poolId: Scalars["ID"]["output"];
poolCandidateId: Scalars["ID"]["output"];
};
}

export const ViewPoolCandidatePage = () => {
const intl = useIntl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,9 @@ export const AssessmentPlanBuilder = ({
);
};

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
poolId: Scalars["ID"]["output"];
};
}

const AssessmentPlanBuilderPage_Query = graphql(/* GraphQL */ `
query AssessmentPlanBuilderPage($poolId: UUID!) {
Expand Down
5 changes: 2 additions & 3 deletions apps/web/src/pages/Pools/EditPoolPage/EditPoolPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -815,10 +815,9 @@ const EditPoolPage_Query = graphql(/* GraphQL */ `
}
`);

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
poolId: Scalars["ID"]["output"];
};
}

const context: Partial<OperationContext> = {
additionalTypenames: ["PoolSkill"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,9 @@ const ManageAccessPage_PoolQuery = graphql(/* GraphQL */ `
}
`);

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
poolId: Scalars["ID"]["output"];
};
}

const ManageAccessPoolPage = () => {
const { poolId } = useRequiredParams<RouteParams>("poolId");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1282,10 +1282,9 @@ const PoolNotFound = () => {
);
};

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
poolId: Scalars["ID"]["output"];
};
}

const PoolAdvertisementPage_Query = graphql(/* GraphQL */ `
query PoolAdvertisementPage($id: UUID!) {
Expand Down
5 changes: 2 additions & 3 deletions apps/web/src/pages/Pools/PoolLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,9 @@ const PoolLayout_Query = graphql(/* GraphQL */ `
}
`);

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
poolId: string;
};
}

const PoolLayout = () => {
const { poolId } = useRequiredParams<RouteParams>("poolId");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ import RequireAuth from "~/components/RequireAuth/RequireAuth";
import { transformFormValuesToFilterState } from "~/components/AssessmentStepTracker/utils";
import { FormValues } from "~/components/AssessmentStepTracker/types";

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
poolId: Scalars["ID"]["input"];
};
}

const ScreeningAndEvaluation_PoolQuery = graphql(/* GraphQL */ `
query ScreeningAndEvaluation_Pools(
Expand Down
5 changes: 2 additions & 3 deletions apps/web/src/pages/Pools/ViewPoolPage/ViewPoolPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,9 @@ export const ViewPool = ({
);
};

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
poolId: Scalars["ID"]["output"];
};
}

const ViewPoolPage_Query = graphql(/* GraphQL */ `
query ViewPoolPage($id: UUID!) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,12 +638,11 @@ const ExperienceFormData_Query = graphql(/* GraphQL */ `
}
`);

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
userId: Scalars["ID"]["output"];
experienceType: ExperienceType;
experienceId: Scalars["ID"]["output"];
};
}

interface ExperienceFormContainerProps {
edit?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ const subTitle = defineMessage({
description: "Subtitle for the request confirmation page.",
});

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RequestConfirmationParams = {
interface RouteParams extends Record<string, string> {
requestId: Scalars["ID"]["output"];
};
}

const mailLink = (chunks: ReactNode) => (
<Link external href="mailto:[email protected]">
Expand All @@ -46,8 +45,7 @@ const mailLink = (chunks: ReactNode) => (
export const Component = () => {
const intl = useIntl();
const paths = useRoutes();
const { requestId } =
useRequiredParams<RequestConfirmationParams>("requestId");
const { requestId } = useRequiredParams<RouteParams>("requestId");

const formattedPageTitle = intl.formatMessage(pageTitle);
const formattedSubTitle = intl.formatMessage(subTitle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import RequireAuth from "~/components/RequireAuth/RequireAuth";

import ViewSearchRequestApi from "./components/ViewSearchRequest";

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
searchRequestId: Scalars["ID"]["output"];
};
}

export const SingleSearchRequestPage = () => {
const { searchRequestId } = useRequiredParams<RouteParams>("searchRequestId");
Expand Down
5 changes: 2 additions & 3 deletions apps/web/src/pages/SkillFamilies/UpdateSkillFamilyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,9 @@ export const UpdateSkillFamilyForm = ({
);
};

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
skillFamilyId: Scalars["ID"]["output"];
};
}

const UpdateSkillFamilyData_Query = graphql(/* GraphQL */ `
query SkillFamilySkillsData($id: UUID!) {
Expand Down
5 changes: 2 additions & 3 deletions apps/web/src/pages/Skills/UpdateSkillPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,9 @@ export const UpdateSkillForm = ({
);
};

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
skillId: Scalars["ID"]["output"];
};
}

const UpdateSkillData_Query = graphql(/* GraphQL */ `
query UpdateSkillData($id: UUID!) {
Expand Down
5 changes: 2 additions & 3 deletions apps/web/src/pages/Skills/UpdateUserSkillPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -769,10 +769,9 @@ export const UpdateUserSkillForm = ({
);
};

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
skillId: Scalars["ID"]["output"];
};
}

const UpdateUserSkill_Query = graphql(/* GraphQL */ `
query UserSkill($skillId: UUID!) {
Expand Down
5 changes: 2 additions & 3 deletions apps/web/src/pages/Teams/TeamLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,9 @@ const TeamLayoutTeamName_Query = graphql(/* GraphQL */ `
}
`);

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
teamId: string;
};
}

const TeamLayout = () => {
const { teamId } = useRequiredParams<RouteParams>("teamId");
Expand Down
5 changes: 2 additions & 3 deletions apps/web/src/pages/Teams/TeamMembersPage/TeamMembersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,9 @@ const TeamMembersTeam_Query = graphql(/* GraphQL */ `
}
`);

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
teamId: Scalars["ID"]["output"];
};
}

const TeamMembersPage = () => {
const { teamId } = useRequiredParams<RouteParams>("teamId");
Expand Down
5 changes: 2 additions & 3 deletions apps/web/src/pages/Teams/UpdateTeamPage/UpdateTeamPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ const UpdateTeamData_Query = graphql(/* GraphQL */ `
}
`);

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
teamId: string;
};
}

const EditTeamPage = () => {
const intl = useIntl();
Expand Down
5 changes: 2 additions & 3 deletions apps/web/src/pages/Teams/ViewTeamPage/ViewTeamPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ import RequireAuth from "~/components/RequireAuth/RequireAuth";

import ViewTeam, { ViewTeamPageFragment } from "./components/ViewTeam";

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RouteParams = {
interface RouteParams extends Record<string, string> {
teamId: Scalars["ID"]["output"];
};
}

interface ViewTeamContentProps {
teamQuery: ViewTeamPageFragment;
Expand Down
Loading

0 comments on commit 0e9824a

Please sign in to comment.