P.optional(subpattern) takes a sub pattern and returns a pattern which matches if the key is undefined or if it is defined and the sub pattern matches its value.
P.optional(subpattern)
Read the documentation for P.optional on GitHub
P.optional
match(value) .with({ greeting: P.optional('Hello') }, () => 'will match { greeting?: "Hello" }') Copy
match(value) .with({ greeting: P.optional('Hello') }, () => 'will match { greeting?: "Hello" }')
P.optional(subpattern)
takes a sub pattern and returns a pattern which matches if the key is undefined or if it is defined and the sub pattern matches its value.Read the documentation for
P.optional
on GitHub