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

Mark array filter values readonly #443

Merged
merged 1 commit into from
Jul 17, 2023

Conversation

wyozi
Copy link
Contributor

@wyozi wyozi commented Jul 13, 2023

What kind of change does this PR introduce?

Mark arrays accepted by filter builder methods readonly.

What is the current behavior?

Currently filter builder methods accept non-readonly arrays. This is fine, but forces casting readonly arrays to non-readonly versions even though Supabase methods do not mutate the passed-in arrays.

See:

const ALLOWED_STATUSES = ["ACCEPTED", "PENDING"] as const;

supabase.from("tasks")
  .select()
  .eq("status", ALLOWED_STATUSES) // tsc error: Argument of type 'readonly (..)[]' is not assignable to parameter of type '(..)[]'.

What is the new behavior?

All filter builders accepting arrays will accept the readonly version. Since this only changes function parameter signature and none of the returned values, it should be a non-breaking change.

Additional context

Quite many libraries (and notably, Typescript's own as const) use readonly arrays, so this makes working with them a bit easier and less-casting-needed.

Copy link
Member

@soedirgo soedirgo left a comment

Choose a reason for hiding this comment

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

Thanks!

@soedirgo soedirgo merged commit 2f4df87 into supabase:master Jul 17, 2023
1 check passed
@wyozi wyozi deleted the filters-readonly-arrays branch July 17, 2023 06:20
@github-actions
Copy link

github-actions bot commented Aug 6, 2023

🎉 This PR is included in version 1.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants