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
Thanks for logging this! It looks like a bug with the way Expo/babel are parsing the TypeScript output for decorators.
I have my tsconfig target set to ES2022, so as long as the parser supports at least that, it should work out of the box.
I'm not sure about intersection.equals being undefined in hermes, but given that it works in every other runtime I've tested, it also seems worth opening an issue with the maintainers of that project to see if they have an idea what's going on.
I'm happy to try and accommodate this environment if there are specific, targeted changes I can make to do so.
I can't say for sure what was in the newer releases that wasn't in that one, but I can say I can't maintain a limited feature set based on what Hermes supports going forward.
If there's a specific problem I can easily address please do let me know as I'd love to help. I'll close this issue for now.
I encountered the same issue as described above. After investigating the cause, I found that in the Hermes environment, the prototype of the instance returned by the invert method of the Disjoint class is the prototype of Array, not Disjoint. In other words, the intersection instanceof Disjoint code in the union.ts file evaluates to false. (I believe the withPrefixKey method might have the same issue.)
While the ArkType code itself seems correct according to ECMAScript specifications (which expect a Disjoint instance to be returned), I was wondering if you might consider making some adjustments for better runtime compatibility across different environments.
Thank you for creating such an excellent library. It has been providing me with a great development experience!
I managed to get it working in my environment by modifying the code as follows:
This worked for me too, thanks a bunch @mark-lendit. I had spent a while trying to get things working in React Native without any luck.
In case it helps anyone else, these are the steps that got arktype working in my Expo project. I'm not positive if they are all required, but I tried a number of combinations without luck:
Install babel-plugin-transform-import-meta and use it in babel.config.js. I used this setting specifically:
Make the change to @ark/schema/out/shared/disjoint.js as described by @mark-lendit .
Add config.resolver.unstable_enablePackageExports = true to metro.config.js.
Used node version 22. I'm not sure what was going on here, but that was the last step that got things working. Weirdly, I can now run things with node 18.
I'm using yarn, also not sure if it matters, but had some different problems with pnpm before.
If you are getting things setup, don't forget to clear your build cache, eg npx expo start --clear.
Happy that I can use Arktype now, it seems excellent.
@mark-lendit Thanks so much for root causing this! I'm going to reopen this issue to track making the suggested adjustment to the package and hopefully adding some CI tests for Hermes.
Just updated this in 2.1.4 (fixed)! Hopefully that addresses the immediate problem.
I'd like to get a more permanent solution in place for testing if anyone here has an idea of the most straightforward way to execute vanilla-JS logic like ArkType's test suite with hermes, would love to get some help:
Just updated this in 2.0.4! Hopefully that addresses the immediate problem.
I'd like to get a more permanent solution in place for testing if anyone here has an idea of the most straightforward way to execute vanilla-JS logic like ArkType's test suite with hermes, would love to get some help:
@ssalbdivad Thank you for your quick work! You mentioned that the issue was fixed in version 2.0.4, but I believe it’s 2.1.4. I have confirmed that the problem has been resolved in 2.1.4. Thank you once again.
@salemkode It looks like it's not resolving package.json's exports field. exports has been supported since Node 12 and apparently has been in React Native for a couple years, though I'm not sure what if anything needs to be done to enable it at this point:
If you get @ark/schema/config could not be found error in your Expo/React Native project, you need to add unstable_enablePackageExports: true to your metro config.
Activity
ssalbdivad commentedon Jun 24, 2024
Thanks for logging this! It looks like a bug with the way Expo/babel are parsing the TypeScript output for decorators.
I have my tsconfig target set to
ES2022, so as long as the parser supports at least that, it should work out of the box.I'm not sure about intersection.equals being undefined in hermes, but given that it works in every other runtime I've tested, it also seems worth opening an issue with the maintainers of that project to see if they have an idea what's going on.
I'm happy to try and accommodate this environment if there are specific, targeted changes I can make to do so.
eduardo-gualberto commentedon Jun 24, 2024
Thank you for replying so quickly!
It seems there are quite a few problems just like that with the hermes interpreter, not my lucky day.
The crazy thing is that using version 2.0.0-dev.0 of ArkType the problem seems to go away.
ssalbdivad commentedon Jun 24, 2024
I can't say for sure what was in the newer releases that wasn't in that one, but I can say I can't maintain a limited feature set based on what Hermes supports going forward.
If there's a specific problem I can easily address please do let me know as I'd love to help. I'll close this issue for now.
dolgim commentedon Feb 13, 2025
Hello!
I encountered the same issue as described above. After investigating the cause, I found that in the Hermes environment, the prototype of the instance returned by the
invertmethod of theDisjointclass is the prototype ofArray, notDisjoint. In other words, theintersection instanceof Disjointcode in theunion.tsfile evaluates tofalse. (I believe thewithPrefixKeymethod might have the same issue.)This seems to be related to Hermes' limitations, specifically the "use of constructor property when creating new Arrays in Array.prototype methods" or lack of support for
Symbol.speciesas mentioned in the Hermes documentation (https://github.com/facebook/hermes/blob/main/doc/Features.md).I managed to get it working in my environment by modifying the code as follows:
invert(): Disjoint { - return this.map(entry => ({ + return new Disjoint(...this.map(entry => ({ ...entry, l: entry.r, r: entry.l - })) as Disjoint + }))) }While the ArkType code itself seems correct according to ECMAScript specifications (which expect a
Disjointinstance to be returned), I was wondering if you might consider making some adjustments for better runtime compatibility across different environments.Thank you for creating such an excellent library. It has been providing me with a great development experience!
bsluther commentedon Mar 4, 2025
This worked for me too, thanks a bunch @mark-lendit. I had spent a while trying to get things working in React Native without any luck.
In case it helps anyone else, these are the steps that got
arktypeworking in my Expo project. I'm not positive if they are all required, but I tried a number of combinations without luck:babel-plugin-transform-import-metaand use it inbabel.config.js. I used this setting specifically:@ark/schema/out/shared/disjoint.jsas described by @mark-lendit .config.resolver.unstable_enablePackageExports = truetometro.config.js.yarn, also not sure if it matters, but had some different problems withpnpmbefore.npx expo start --clear.Happy that I can use Arktype now, it seems excellent.
ssalbdivad commentedon Mar 4, 2025
@mark-lendit Thanks so much for root causing this! I'm going to reopen this issue to track making the suggested adjustment to the package and hopefully adding some CI tests for Hermes.
ssalbdivad commentedon Mar 5, 2025
Just updated this in
2.1.4(fixed)! Hopefully that addresses the immediate problem.I'd like to get a more permanent solution in place for testing if anyone here has an idea of the most straightforward way to execute vanilla-JS logic like ArkType's test suite with hermes, would love to get some help:
#1340
dolgim commentedon Mar 5, 2025
@ssalbdivad Thank you for your quick work! You mentioned that the issue was fixed in version
2.0.4, but I believe it’s2.1.4. I have confirmed that the problem has been resolved in2.1.4. Thank you once again.ssalbdivad commentedon Mar 5, 2025
@mark-lendit Whoops, yes thanks for the correction!
salemkode commentedon Mar 24, 2025
I have another issues in expo ~52.0.39
ssalbdivad commentedon Mar 24, 2025
@salemkode It looks like it's not resolving
package.json'sexportsfield.exportshas been supported since Node 12 and apparently has been in React Native for a couple years, though I'm not sure what if anything needs to be done to enable it at this point:https://reactnative.dev/blog/2023/06/21/package-exports-support
shovel-kun commentedon Apr 11, 2025
If you get
@ark/schema/config could not be founderror in your Expo/React Native project, you need to addunstable_enablePackageExports: trueto your metro config.Example:
🪲 Fix arktype setup
fix: Hermes withPrefixKey crash and Turbopack static `this` in scope.…