react-native-worklets-core
react-native-worklets-core copied to clipboard
Support for ts-pattern.match() inside worklets
🧠Feature Request: Support for ts-pattern.match() inside Reanimated worklets
I'm requesting support for using ts-pattern's match() function inside worklets
🧪 Current Behavior
Using ts-pattern.match inside a worklet results in the following runtime
ts-pattern.match() causes [Reanimated] Tried to synchronously call a non-worklet function on the UI thread
💡 Why This Matters
-
ts-pattern enables exhaustive, type-safe pattern matching in TypeScript.
-
Many developers reach for this library to improve control flow and readability, including in animations or shared UI logic.
-
However, worklet context throws errors because match() creates closures and uses non-serializable logic.
https://github.com/gvergnaud/ts-pattern/issues/320