You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was able to hack build enough to get some typed coded into app, but it fails during runtime, even simple expressions like var num: number = 42; will throw syntax error.
I am not sure what's wrong, does Static Hermes need some additional config/flags to be able to process TS code during runtime? And how can I even tell that I am running Static Hermes and not normal Hermes? Are there any internals that I can log to see if it's correct version?
Solution
Additional Context
The text was updated successfully, but these errors were encountered:
As I expected you need to pass -typed arg to process starting Static Hermes in file node_modules/react-native/scripts/react-native-xcode.sh around line ~176 or use $EXTRA_COMPILER_ARGS="-typed" env variable in .xcode.env
Second issue was build pipeline which of course strips all types using Babel. I managed to create solution where I used Metro custom transformer option to transform some files (for example with .shermes.ts suffix) differently. I used modular nature of Typescript compiler and some of it's internal function to transform code in this files to CommonJS and ES6 (which should work in RN) but also to keep types in source code. This was very hacky-glued solution but it produced code that looked okay with preserved types 🎉
But sadly that was my last win, even that I was able to get some typed code into Static Hermes compiler I started getting lot of Segmentation fault errors. Lot of them was in React source code or in React Native Fabric JS part of code. I fixed quite a big amount of them. Sometimes it was like changing null === a to a === null etc. but there were too many of them and it was clearly not good direction.
In the end I removed all my experimental typed code and tried to compile untyped code of just RN and sadly that is not possible too when Hermes -typed mode is enabled 😢
I am not giving up yet. One idea that I have, is to somehow convince Static Hermes to compile in -typed mode only some functions that are annotated with some comment for example. But to be fair I am not familiar with internals of Hermes at all and also not much proficient with C++ so maybe this will be impossible due to architecture of Hermes, but IDK. Would be nice if someone with more experience with Static Hermes can tell me if this is even worth exploring or it's totally waste of time.
Problem
I was able to hack build enough to get some typed coded into app, but it fails during runtime, even simple expressions like
var num: number = 42;
will throw syntax error.I am not sure what's wrong, does Static Hermes need some additional config/flags to be able to process TS code during runtime? And how can I even tell that I am running Static Hermes and not normal Hermes? Are there any internals that I can log to see if it's correct version?
Solution
Additional Context
The text was updated successfully, but these errors were encountered: