The output result is different from what was expected!
Closed this issue · 1 comments
kristy-zhj commented
import { match, P } from "ts-pattern"
type Input = { title: string; content: string }[]
let input: Input = [
{ title: "Hello world!", content: "This is a very interesting content" },
{ title: "Bonjour!", content: "This is a very interesting content too" },
]
const output = match(input)
.with(
P.array({
title: "Hello world!",
content: P._,
}),
(posts) => "a list of posts!"
)
.otherwise(() => "something else")
console.log(output) //something else
expect: a list of posts!
package.json
"ts-pattern": "^5.5.0",
"react": "^18.2.0",
gvergnaud commented
This behaves as expected: P.array({ title: "Hello world!", content: P._, })
doesn't match your input because not all post titles are equal to "Hello world!"