You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Optimize JSXSpreadAttribute JS emit when it contains ObjectLiteralExpression #49099
I've noticed that TypeScript emits a different JS output for some cases involving JSXSpreadAttribute that contains ObjectLiteralExpression than Babel. It seems that Babel has decided to optimize some of the situations and tries to avoid emitting unnecessary Object.assign calls/spread assignments.
Sure, stuff like this can be detected in the algorithm and we might skip this optimization if there is __proto__ in the spread object. It seems though that Babel doesn't quite care about this and applies this optimization regardless of that (might be a bug in their code, maybe it's worth reporting there).
I'd definitely call it a bug in their code - I'm ok skipping the call when we statically know it's definitely safe, but there are definitely cases where it isn't.
Activity
RyanCavanaugh commentedon May 13, 2022
Wesley Wigham (@weswigham) any concerns? Seems fine to me to match Babel
weswigham commentedon May 13, 2022
It's not a safe transform to make if a property in the object is named
__proto__.Andarist commentedon May 13, 2022
Sure, stuff like this can be detected in the algorithm and we might skip this optimization if there is
__proto__in the spread object. It seems though that Babel doesn't quite care about this and applies this optimization regardless of that (might be a bug in their code, maybe it's worth reporting there).weswigham commentedon May 14, 2022
I'd definitely call it a bug in their code - I'm ok skipping the call when we statically know it's definitely safe, but there are definitely cases where it isn't.