-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot read property 'USER_SPACE_ON_USE' of undefined #1210
Comments
I've added repo with minimal source code for reproduction https://github.com/likern/SVGTest |
Thanks for reporting, would you mind making a pr to fix this? |
How would I go about solving this issue? Would exporting the enum from a ts declaration file work? |
Workaround is already provided in the original message |
@likern yes I see :) I am just trying to figure out how I would go about solving this issue via a PR, and allow users to use:
in the correct way |
I think |
Should probably import the units from /src/lib/units.ts into src/ReactNativeSVG.ts and export it from there, and also to use that type in all the places where |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open. |
Getting same error, TypeError: Cannot read property 'USER_SPACE_ON_USE' of undefined
|
hey , can any one guide here any begineer friendly issue ? |
Bug
Enums should not be placed to index.d.ts files, because they are not processed by Babel.
Now Typescript is used as type-checking in React Native and whole conversion from tsx to js is done by https://babeljs.io/docs/en/next/babel-plugin-transform-typescript.
This plugin doesn't process *.d.ts files:
Link to comment babel/babel#10502 (comment)
But Enums are not only types, but are real runtime objects, so they becomes undefined on import.
Environment info
React native info output:
Library version: "react-native-svg": "^9.13.3"
Steps To Reproduce
Describe what you expected to happen:
This is a workaround code, where Enums are used only for type-checking
This is a invalid code, where Enums are used at runtime.
Reproducible sample code
Repository with reproduction https://github.com/likern/SVGTest
Helpful links:
https://lukasbehal.com/2017-05-22-enums-in-declaration-files
The text was updated successfully, but these errors were encountered: