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

Vacms 15949 cleanup #243

Merged
merged 7 commits into from
Nov 27, 2023
Merged

Vacms 15949 cleanup #243

merged 7 commits into from
Nov 27, 2023

Conversation

ryguyk
Copy link
Contributor

@ryguyk ryguyk commented Nov 16, 2023

Description

Closes department-of-veterans-affairs/va.gov-cms#15949

This is a refactor. No functionality is changed.

Our TypeScript types needed some cleanup and normalization. This PR goes a long way toward accomplishing that. The cleanup uncovered a few silent issues with some types that are also resolved by this PR, but the bulk of the work boils down to implementing this model:

  • TypeScript types for data can be thought of as before and after formatting. Types for before formatting are in types/dataTypes/drupal. Types for after formatting are in types/dataTypes/formatted.
  • Pre-formatted types are types specific to Drupal. If we added another data source or replaced Drupal altogether, types for the new data source could augment or replace these types. Those new types would get formatted into the same formatted types.
  • In this way, our application logic is decoupled from the specifics of the data source. Our business logic can be written to use the normalized/formatted data properties.

This model was already largely implemented, but it wasn't clean or explicit. Additionally, there were a number of places (and still might be a few) where "formatted" data types contained properties that were pre-formatted types. This sort of mixing is ripe for confusion at least, and, more than likely, bugs.

Another thing that is noteworthy is that this PR removes index.d.ts. That file held the bulk of the formatted type definitions, but naming it with the .d.ts extension was not entirely correct. That extension is generally reserved for defining types for external libraries. Using it here led to some silent type mismatches. The result of the move, as mentioned above, uncovered these previously silent type problems, so this PR addresses those as well.

Testing done/QA steps

  • Ensure existing unit tests still pass
  • Ensure build still succeeds.
  • A lot of manual QA. This changes a ton of files, and it needs to be tested accordingly.

@va-cms-bot va-cms-bot temporarily deployed to Tugboat November 16, 2023 13:41 Destroyed
src/lib/drupal/drupalClient.ts Outdated Show resolved Hide resolved
src/lib/drupal/staticPaths.ts Outdated Show resolved Hide resolved
@va-cms-bot va-cms-bot temporarily deployed to Tugboat November 16, 2023 19:11 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat November 16, 2023 20:56 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat November 18, 2023 12:29 Destroyed
@ryguyk ryguyk marked this pull request as ready for review November 18, 2023 13:13
@va-cms-bot va-cms-bot temporarily deployed to Tugboat November 27, 2023 17:17 Destroyed
Copy link
Contributor

@tjheffner tjheffner left a comment

Choose a reason for hiding this comment

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

thank you for tackling this cleanup, it reads much better! and will be much easier to extend in the future, thanks to the now clearly explicit drupal / formatted type split

@tjheffner tjheffner merged commit a71a8b3 into main Nov 27, 2023
3 checks passed
@tjheffner tjheffner deleted the VACMS-15949-cleanup branch November 27, 2023 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean up and normalize Next Build Typescript types
3 participants