react-native-worklets-core icon indicating copy to clipboard operation
react-native-worklets-core copied to clipboard

Support for ts-pattern.match() inside worklets

Open salemkode opened this issue 8 months ago • 1 comments

🧠 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.

salemkode avatar May 12 '25 06:05 salemkode

https://github.com/gvergnaud/ts-pattern/issues/320

salemkode avatar May 12 '25 06:05 salemkode