ITADN

patterns of type `P.Pattern` do not work

#340Openadamschoenemann 创建于 2025-12-12
A
adamschoenemanncommented
**Describe the bug** If you have a pattern for a type `A` and you type it as `P.Pattern<A>`, using it in any `match` will cause the inferred type in the handler to be `MixedNamedAndAnonymousSelectError` **TypeScript example** ```typescript type A = { type: "A"; a: string }; const patternA: P.Pattern<A> = { type: "A" as const, a: P.string, }; const testPatterMatch = (x: A) => { return match(x) // x has type MixedNamedAndAnonymousSelectError<"Mixing named selections (`select(\"name\")`) and anonymous selections (`select()`) is forbiden. Please, only use named selections."> .with(patternA, (x) => `Matched A with b: ${x.a}`) .exhaustive(); } ``` **Versions** - TypeScript version: 5.9.3 - ts-pattern version: 5.9.0
2 条评论