Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this change?
Gareth's work here, where he rightly reused existing helpers made me realise that we were repeating some logic and defaults IDs at various points. I wanted to streamline it, make it potentially easier to add new types to (although when will that ever happen 😄 ). Would recommend reviewing without whitespace.
I do think it helps with readability and maintainability as well.
How to test
Run some tests scripts, see if it's expected results!
Run
update-prismic-snapshot
to see if it still works as expected.How can we measure success?
Typescript is actually useful and we can add types/modify the tests/default IDs easily and in one place.
Have we considered potential risks?
This is mostly for testing purposes, but it also affected
update-prismic-snapshot
, so there could be that, although the only change is a check if the type isn't valid. I re-ran the snapshots locally and it looks alright to me.