-
Notifications
You must be signed in to change notification settings - Fork 34
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
Error when replacing with booleans #85
Comments
This behavior description is accurate. So, we tackled things with bindings in #81 I'm not totally sure if we should skip object keys or if there are legitimate use cases to replace those.... Thoughts @carloskelly13 @gksander ? As an aside, if you switch to string keys, you can get an equivalent, non-error output: const obj = {
"__DEV__": __DEV__
}; outputs to: var obj = {
"__DEV__": true
}; |
Thanks for opening that issue @tomekzaw . I can see different cases: const obj = {
__DEV__
};
const obj = {
__DEV__: __DEV__
};
const obj = {
"__DEV__": __DEV__
};
const obj = {
["__DEV__"]: __DEV__
}; Should output: var obj = {
"__DEV__": true
}; Meanwhile const obj = {
[__DEV__]: __DEV__
}; Should be the only one that also affect the key |
Agreed, in my view |
Hello there, gentle nudge to the issue, since I feel we all agree on the problem, what are the steps moving forward, should we expect you guys to fix it at some time or will you want a pull request? |
Went ahead and created the PR |
gentle nudge @ryan-roemer @carloskelly13 @gksander |
Hi @Titozzz - thanks for resurfacing this. I'm a bit swamped this week, but will try to check this out first thing next week! |
Okay, this fix has been released as |
Hey! Thanks for the plugin. There seems to be some problem when using it with React Native Reanimated (originally reported by @Titozzz). After some debugging, it turns out that babel-plugin-transform-define also tries to replace the names of JS object keys which is not expected. Here's the minimal reproducible example:
Input:
Options:
Error:
TypeError: (...) Property key of ObjectProperty expected node to be of a type ["Identifier","StringLiteral","NumericLiteral"] but instead got "BooleanLiteral"
Expected:
Note that it's possible to use
[__DEV__]
as the key, in such case it should be replaced.The text was updated successfully, but these errors were encountered: