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

Support P.object.empty #230

Open
gitsunmin opened this issue Mar 19, 2024 · 1 comment
Open

Support P.object.empty #230

gitsunmin opened this issue Mar 19, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@gitsunmin
Copy link

Is your feature request related to a problem? Please describe.
This idea stems from the issue discussed below.

#228

Describe the solution you'd like
I would like support for P.object.empty, as discussed in the issue above.

Describe alternatives you've considered
I have considered P.empty as well, but it might be ambiguous in some cases. Please comment if there are other suggestions.

Additional context
Here is an example of using P.object.empty:

const x:Array<string> | Set<number> | Partial<SomeObject> = {}

match(x)
.with(P.object.empty, ()=>"fallback")
.otherwise(()=>"Meh")
@gitsunmin gitsunmin added the enhancement New feature or request label Mar 19, 2024
@gvergnaud
Copy link
Owner

Looks good to me. P.object could match anything assignable to the object type as well

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

No branches or pull requests

2 participants