Skip to content

[FIX] Core typescript errors #3453

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

Merged
merged 11 commits into from
Mar 11, 2025
Merged

[FIX] Core typescript errors #3453

merged 11 commits into from
Mar 11, 2025

Conversation

sggerard
Copy link
Collaborator

@sggerard sggerard commented Mar 7, 2025

Objective

Fix almost all the typescript errors in CORE.

There are only 2 remaining, MineAlert and MinePermitInfo which both need to be rewritten as Functional Components.
Using the connector props won't fix these as they need to be using the typed Dispatch.
image

Key changes:

  • Added interfaces (Including to Search!)
  • Prettier may have had a go at some indentation argh
  • Swapped useDispatch and useSelector for useAppDispatch and useAppSelector where needed
  • Cast formValues to Interfaces
  • Did some ugly connector props joining
  • Updated the redux-form-input-masks library to fix bad typing.

@sggerard sggerard changed the title [Fix] Core typescript errors [FIX] Core typescript errors Mar 7, 2025
export interface DropdownOption {
value: string;
label: string;
isActive?: boolean;
Copy link
Collaborator

@taraepp taraepp Mar 7, 2025

Choose a reason for hiding this comment

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

I wonder if we just want to add these properties to IOption? Because value/label is required in both and the rest is optional

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeeeeah it looks like where it's used is being passed into RenderSelect/RenderMultiSelect, which expects IOption for it. May as well make it the same

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Cool, done

const documents = useAppSelector((state) => selector(state, "documents")) || [];
const formValues = useAppSelector((state) => getFormValues(FORM.ADD_EDIT_INCIDENT)(state)) || {};
const dropdownIncidentStatusCodeOptions = useAppSelector(getDropdownIncidentStatusCodeOptions);
const isPristine = useAppSelector((state) => state.form[FORM.ADD_EDIT_INCIDENT]?.pristine);
Copy link
Collaborator

@taraepp taraepp Mar 7, 2025

Choose a reason for hiding this comment

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

perhaps a little out of scope, but there is a redux-form selector isPristine(formName) that doesn't depend on knowing the state structure. You would have to rename the const isPristine though, to use it. Actually, seeing how we have formValueSelector on ln 68, used in 69, and then followed by getFormValues, this file probably needs a little more love in general.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have refactored it a little :)

@sggerard sggerard added the 👍 Ready for review Pull request has been double checked by the author and is ready for comments and feedback. label Mar 7, 2025
@sggerard sggerard requested a review from taraepp March 7, 2025 20:39
@@ -164,7 +163,7 @@ export const IncidentForm: FC<IncidentFormProps> = (props) => {
/>
<br />
<IncidentFormInternalDocumentComments
documents={documents}
documents={formValues?.documents}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we might want to null coalesce these to []- looks like both IncidentFormDocuments and IncidentFormInternalDocumentComments does a documents.filter which will probably blow up with undefined

Copy link

sonarqubecloud bot commented Mar 7, 2025

Quality Gate Passed Quality Gate passed for 'bcgov-sonarcloud_mds_minespace-web'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

Copy link

sonarqubecloud bot commented Mar 7, 2025

Quality Gate Failed Quality Gate failed for 'bcgov-sonarcloud_mds_common'

Failed conditions
34.9% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Copy link

sonarqubecloud bot commented Mar 7, 2025

Quality Gate Failed Quality Gate failed for 'bcgov-sonarcloud_mds_core-web'

Failed conditions
66.1% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@sggerard sggerard merged commit 7953999 into develop Mar 11, 2025
15 of 17 checks passed
@sggerard sggerard deleted the fix-core-typescript-errors branch March 11, 2025 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👍 Ready for review Pull request has been double checked by the author and is ready for comments and feedback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants