ITADN

const/literal handlers

#334Openzacaj 创建于 2025-10-14
enhancement
Z
zacajcommented
**Is your feature request related to a problem? Please describe.** When trying to use ts-pattern to match cases to a string type union (eg, `'case-1' | 'case-2'`), the syntax is unnecessarily verbose. I need to write `() => ` every time, and then also add `as const` after each value, or repeat the options in `returnType<...>()` to get a proper type out **Describe the solution you'd like** It would be nice if the types for handlers accepted either a function with a given return type OR a value with that type, in the case where no data from the matcher is needed, and thus ts-pattern would have access to the specific value instead of just `string` to determine its returnType implicitly. Add any other context or screenshots about the feature request here.
4 条评论