Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

Allow params in fact and event to be an array of Record<K,T>#422

Open
aprakhar wants to merge 1 commit intoCacheControl:master from
aprakhar:feat-params-be-array-of-records
Open

Allow params in fact and event to be an array of Record<K,T> #422
aprakhar wants to merge 1 commit intoCacheControl:master from
aprakhar:feat-params-be-array-of-records

Conversation

@aprakhar
Copy link

@aprakhar aprakhar commented Aug 4, 2025

The params property in fact and event, support an array of Record<Keys, Type>.
I've updated the Typescript type of params. I've moved the type into TParams, which replaces Record<string, any>

@aprakhar aprakhar marked this pull request as ready for review August 4, 2025 06:40
Copy link
Collaborator

Thanks for the PR @aprakhar!

I think this change as-is would be a breaking change at the type level. Specifically, DynamicFactCallback changes its params parameter from Record<string, any> to Record<string, any> | Record<string, any>[]. That means anyone implementing a dynamic fact callback today would get a type error — their existing (params: Record<string, any>, almanac) => ... signatures would no longer satisfy the widened union without narrowing it first.

Similarly, consumers reading ConditionProperties.params from rule results who have typed their code assuming it's always a record would also break.

Widening input types (like ConditionProperties.params when constructing rules) is fine, but widening callback parameters and output types is a breaking change since it forces consumers to handle a new case.

One option would be to scope this to just the input positions (e.g. where users are defining conditions/events) while keeping the callback and result types unchanged. Alternatively this could be something we pick up in the next major version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /