gvergnaud/ts-pattern

Support P.object.empty

gitsunmin opened this issue · 1 comments

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")

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