It is possible that the creation of a const Object = ... may be confusing the tooling where it may be interpreting the Object variable with globalThis.Object (which may or may not be polyfilled for the react native environment on build, I don't know). You should be able to repo the issue without by creating a Object variable (uppercase) and seeing if that triggers the error. I have seen similar behaviors before, but mostly they are related to something misbehaving in a tool or plugin somewhere.
If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.
(Optional) Comment the line const Object = ''; to make the example not throw the error message
What is the expected behavior?
It should be possible to have a variable named Object, as this is a valid javascript variable name. Libraries are breaking using Metro (for example, TypeBox) due to this.
Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
If there is a variable named
Object
present in a react native app, it throws the error:
Quoting from the original issue raised in: https://github.com/sinclairzx81/typebox/issues/968
If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can
yarn install
andyarn test
.const Object = '';
to make the example not throw the error messageWhat is the expected behavior?
It should be possible to have a variable named Object, as this is a valid javascript variable name. Libraries are breaking using Metro (for example, TypeBox) due to this.
Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
Metro: default expo metro config. Node: v20.12.0 Bun: 1.1.26 Operating system: macOS, 14.5, 23F79