Static Hermes Typed Mode Compatibility - Investigation & Tracking #5912
Replies: 1 comment
-
|
This is a really interesting investigation. A few thoughts on the compatibility question: The typed mode blockers you identified are fundamental to how Effect is architected — computed property names for For Option 2 (compilation target), this is probably the most viable path. A Babel/SWC transform that:
These transforms already exist in the TypeScript/Babel ecosystem (they were needed for older ES targets). The challenge is that Static Hermes typed mode needs to understand the transformed output for type inference — and the WeakMap pattern for private fields would likely lose type information. For Option 3 (Effect-lite), this might make the most practical sense for React Native scenarios. A minimal subset that covers Realistically, I think waiting for Static Hermes to expand its supported feature set (Option 1) is the path of least resistance. Computed property names and private fields are standard ECMAScript — not exotic patterns — so the Hermes team will likely need to support them eventually for broader TypeScript compatibility. Filing issues with the Hermes team for computed property names and optional call expressions would be the most impactful next step. The untyped mode being 3x slower than Node.js is expected since Effect relies heavily on megamorphic call sites and closure allocation, which benefit enormously from V8's JIT optimizations that an AOT compiler cannot replicate without type information. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
This discussion tracks the compatibility between Effect and Static Hermes typed mode - Facebook's ahead-of-time compiler that can compile TypeScript to native binaries with C/C++-like performance.
TL;DR: Effect is currently incompatible with Static Hermes typed mode due to several JavaScript patterns that the typed compiler doesn't support. This discussion documents the specific blockers and potential paths forward.
What is Static Hermes Typed Mode?
Static Hermes offers two compilation modes:
shermes -typed): Uses TypeScript/Flow type annotations to generate truly optimized native code, eliminating dynamic dispatch and enabling aggressive inliningThe typed mode is the interesting one for performance-critical applications, as it promises "predictable performance on par with C/C++".
Current Status: ❌ Incompatible
When attempting to compile bundled Effect code with
shermes -typed, the compiler fails with 20+ errors before giving up.Blocking Issues
1. Computed Property Names in Classes
Error:
ft: computed property names in classes are unsupportedThis is fundamental to how Effect implements iterables and type branding throughout the codebase.
2. Private Class Fields
Error:
ft: unsupported class member ClassPrivateProperty3. Optional Chaining on Calls
Error:
ft: optional call expression not supported4. Dynamic Property Access
Error:
ft: unsupported5. Complex Type Inference Patterns
The typed compiler falls back to
anyfor many closure patterns and use ofarguments, losing type benefits:What Works: Untyped Mode ✅
Effect does work with Static Hermes untyped mode. All major features pass:
However, untyped mode is ~3x slower than Node.js for Effect operations, making it less attractive for performance-focused use cases.
Potential Paths Forward
Option 1: Wait for Static Hermes to Expand Support
Static Hermes is under active development. Relevant tracking issues:
Option 2: Effect Compilation Target
Create a build/compilation step that transforms Effect's patterns into typed-mode-compatible code:
[Symbol.iterator]()with explicit iterator implementationsThis would be complex and require maintaining a parallel "static-hermes-compatible" build.
Option 3: Effect-lite for Static Hermes
Create a minimal subset of Effect that avoids incompatible patterns, designed specifically for AOT compilation scenarios.
Option 4: Alternative AOT Compilers
Explore other TypeScript-to-native paths:
Experiment Details
Full experiment report with test code, benchmarks, and detailed error analysis:
https://gist.github.com/schickling/e53f0e65b772c0e62492c99afe3ae2cf
Environment
static_hbranch (December 2025)Reproduction
Questions for Discussion
This discussion was created based on experimental investigation. Please share any additional findings or alternative approaches!
Beta Was this translation helpful? Give feedback.
All reactions