-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
💻
- Would you like to work on a fix?
How are you using Babel?
Programmatic API (babel.transform, babel.parse)
Input code
Configuration file name
No response
Configuration
No response
Current and expected behavior
I have code in SolidJS dom-expressions(https://github.com/ryansolid/dom-expressions) compiler that assigns refs to variables in some cases. We use the t.isLVal check to exclude some amount of conditions that can't be assigned including OptionalMemberExpressions.
Attempting to update our babel versions recently showed that t.isLVal is now true when the passed in node is an OptionalMemberExpression at https://github.com/ryansolid/dom-expressions/blob/main/packages/babel-plugin-jsx-dom-expressions/src/dom/element.js#L563
This changes the output from:
const template36 = (() => {
var _el$52 = _tmpl$4();
var _ref$5 = a().b?.c;
typeof _ref$5 === "function" && _$use(_ref$5, _el$52);
return _el$52;
})();to
const template36 = (() => {
var _el$52 = _tmpl$4();
var _ref$5 = a().b?.c;
typeof _ref$5 === "function" ? _$use(_ref$5, _el$52) : a().b?.c = ref$5;
return _el$52;
})();This is illegal. I don't believe OptionalMemberExpresions can be on the left hand side of an assignment. And the output fails when it gets that.
Environment
babel v7.28.0
node v24.0.1
pnpm v10.10
monorepo lerna
Possible solution
No response
Additional context
No response