Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1487: replaced usage of type any with specific types #2130

Merged
merged 9 commits into from
Mar 18, 2024

Conversation

aarushgarg1110
Copy link
Contributor

Changes

i went through the file and replaced occurrences of any with the appropriate types. I would declare certain variables as number, boolean, string, etc and could delete the any keywords.

Notes

No notes, but would like to make sure I did it correctly or in the format you are looking for

Checklist

It can be helpful to check the Checks and Files changed tabs.
Please review the contributor guide and reach out to your Tech Lead if anything is unclear.
Please request reviewers and ping on slack only after you've gone through this whole checklist.

  • [x ] All commits are tagged with the ticket number
  • [x ] No linting errors / newline at end of file warnings
  • [x ] All code follows repository-configured prettier formatting
  • [x ] No merge conflicts
  • [x ] All checks passing
  • Remove any non-applicable sections of this template
  • [x ] Assign the PR to yourself
  • No yarn.lock changes (unless dependencies have changed)
  • [x ] Request reviewers & ping on Slack
  • [x ] PR is linked to the ticket (fill in the closes line below)

Closes #1487

Copy link
Member

@walker-sean walker-sean left a comment

Choose a reason for hiding this comment

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

This is looking good! Could you create some named interfaces for the payloads (look to the tasks hooks file for examples)? Also, I think your TS check is failing because you need to pull from develop (git pull origin develop).
The TS checks run when you do yarn prisma:reset so you can check it that way

Copy link
Member

@walker-sean walker-sean left a comment

Choose a reason for hiding this comment

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

NICE

@@ -103,41 +111,63 @@ export const useCreateStandardChangeRequest = () => {
);
};

export interface Payload {
Copy link
Member

Choose a reason for hiding this comment

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

Can you please give this a more descriptive name regarding what it's for?

Copy link
Member

@walker-sean walker-sean left a comment

Choose a reason for hiding this comment

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

The two payloads for activation and stage gate change requests should actually be different. You don't see issues here, because we have it set up such that the hooks only use the fields they need, but if you look to where the hooks are implemented, you can see the objects that are passed as arguments do not follow the one payload. You should create two payloads based on the fields passed where the hooks are used.

Copy link
Contributor

@alaneng-neu alaneng-neu left a comment

Choose a reason for hiding this comment

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

Looking good! Just a few small changes

['change requests', 'review'],
async (crReviewPayload: { userIds: number[] }) => {
async (crReviewPayload) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Define the type of crReviewPayload in the async call with the new type you created

@@ -47,7 +47,8 @@ const ProposedSolutionsList: React.FC<ProposedSolutionsListProps> = ({ proposedS
description,
scopeImpact,
timelineImpact,
budgetImpact
budgetImpact,
type: ''
Copy link
Contributor

Choose a reason for hiding this comment

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

Since ProposedSolution type is just a placeholder value you can just remove type from the CreateProposeSolutionPayload type and call mutateAsync without that field

projectLeadId,
projectManagerId,
startDate,
projectLeadId: projectLeadId || 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of doing projectLeadId || 0 in the case that projectLeadId is undefined, use an if statement like above to check if projectLeadId is defined and throw an error if not

projectManagerId,
startDate,
projectLeadId: projectLeadId || 0,
projectManagerId: projectManagerId || 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing here

Copy link
Contributor

@alaneng-neu alaneng-neu left a comment

Choose a reason for hiding this comment

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

little nitpicks

@@ -41,14 +41,20 @@ const ActivateWorkPackageModalContainer: React.FC<ActivateWorkPackageModalContai
const handleConfirm = async ({ projectLeadId, projectManagerId, startDate, confirmDetails }: FormInput) => {
handleClose();
if (auth.user?.userId === undefined) throw new Error('Cannot create activation change request without being logged in');
if (projectLeadId === undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can just use the shorthand of !projectLeadId instead of projectLeadId === undefined

if (projectLeadId === undefined) {
throw new Error('Project Lead Id must be defined to create an activation change request');
}
if (projectManagerId === undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing

Copy link
Contributor

@alaneng-neu alaneng-neu left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@walker-sean walker-sean left a comment

Choose a reason for hiding this comment

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

Nice!

@walker-sean walker-sean merged commit c70c875 into develop Mar 18, 2024
4 checks passed
@walker-sean walker-sean deleted the #1487-remove-any-change-request.hooks branch March 18, 2024 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Refactoring] - Remove any type from src/frontend/src/hooks/change-requests.hooks.ts
3 participants