Open channeladam opened 1 year ago
@channeladam We do have an open issue that we hope to get to in the near future to stop injecting Realm
globally. This would require that Realm
be imported.
In any case, it's strange the babel plugin doesn't add schema
to the class if Realm
isn't imported. We will investigate. Thanks for the issue!
~Babel plugin also does not add a schema
to the class if the class has an implements
keyword.~
~EDIT: hmm, implements
is working for me now... sorry, not sure what happened.~
EDIT: actually there sometimes is a problem... opening a new issue for it. https://github.com/realm/realm-js/issues/5246
Also, the Babel plugin also does NOT add properties to the schema
for constant-named properties.
How frequently does the bug occur?
All the time
Description
The Babel plugin does not add a static schema to my TypeScript file when I don't explicitly import Realm in the ts file. The plugin's import checking apparently only succeeds when and requires that I have Realm directly imported in my .ts file - otherwise it doesn't process the class.
NOTE: I don't get an error in TypeScript when I don't have the import... it seems to globally know about Realm's namespace from /node_modules/realm/types/index.d.ts.
If it passes static analysis in TypeScript, I expect that the schema would be added by the Babel plugin.
This does NOT get a schema added by the Babel plugin (and also does not have a TypeScript error):
This DOES get a schema added by the Babel plugin - because it explicitly imports Realm:
Stacktrace & log output
No response
Can you reproduce the bug?
Yes, always
Reproduction Steps
Remove the import statement from a Realm object.
Version
11.3.1
What SDK flavour are you using?
Local Database only
Are you using encryption?
No, not using encryption
Platform OS and version(s)
Android 11 R API 30 - Pixel 5 emulator
Build environment
Which debugger for React Native: Flpper
Cocoapods version
No response