Repository navigation
Simplify filter types with a value map and capability union - #2655
Merged
rajarsheechatterjee merged 1 commit intoOct 10, 2026
Merged
Conversation
Adding a filter type meant restating its value shape across several declarations. Nothing kept them in sync, and a missing `ValueOfFilter` branch silently became `never`. Consolidate the per-type facts into a value map and a capability union. Each fact is now declared once, and a new capability touches only the types that support it. `WithOptions` is intentionally a positive list, so a new option-bearing type omitted from it defaults to no options instead of erroring — accepted in exchange for the shorter, easier-to-review list. Assisted-By: LLM
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adding a filter type meant restating its value shape across several declarations. Nothing forced the declarations to agree. Omitting a
ValueOfFilterbranch silently becamenever, so an incomplete addition still compiled.Two declarations would now describe a filter type:
FilterValueMapis the value shape per type. It's exhaustive, so miss an entry and you get a type error.WithOptionsis the types that have anoptionsarray.OptionsOf<T>reads from it to add that options array to the resulting filter type.Things don't get repeated as much. A new FilterType with no options is just two entries in one file — the enum and the value map — and the compiler checks the value map. The refactor leaves the resulting filter types structurally identical to before.
Adding a new capability (the options trait is one) just needs a
T extends WithXhelper plus a union of the types that support it. So a PR that gives an existing capability to more types only has to add them to the union, which should be easy to review.Unlike
FilterValueMap,WithOptionsisn't exhaustive, it only lists the types that have options. If a type is left out — say when adding a new FilterType — it doesn't complain or give a type error, it just treats that type as having no options. So a new FilterType with options has to be remembered, but since it stands out in the list I think that's fine.Value shapes are still exhaustive, so those can't be half-added.
Enum names/values, exported symbols, and filter literal shapes are unchanged, so no plugin source needs editing. This mirrors the reader-app change (lnreader/lnreader#2093).
I validated that it linted, formatted, and I ran a strict tsc over the repo, this change adds no new errors.
Let me know if it needs changing.
Code assisted by LLM
Checklist
type(scope): description(e.g.feat(<generator>): add new source)