stylex
stylex copied to clipboard
TypeError: String.prototype.concat called on null or undefined (v0.6.1)
Describe the issue
Seeing the following error on v0.6.1. Code was previously working on v0.6.0
and earlier versions
TypeError: String.prototype.concat called on null or undefined
at concat (<anonymous>)
at transformFile.next (<anonymous>)
at run.next (<anonymous>)
at transform.next (<anonymous>)
I was able to narrow it down to this new null check added in v0.6.1:
https://github.com/facebook/stylex/blob/c48bea12d3f4109a0b6bcce7c68c807972c16620/packages/babel-plugin/src/utils/evaluate-path.js#L693
In our case, we hit the following condition first (isStringLiteral is true) https://github.com/facebook/stylex/blob/c48bea12d3f4109a0b6bcce7c68c807972c16620/packages/babel-plugin/src/utils/evaluate-path.js#L683-L691
^ which defines func
as the string concat function but context
remains undefined.
As a result, calling func later results in TypeError: String.prototype.concat called on null or undefined
being thrown because context is undefined.
https://github.com/facebook/stylex/blob/c48bea12d3f4109a0b6bcce7c68c807972c16620/packages/babel-plugin/src/utils/evaluate-path.js#L725
I was able to workaround this by setting context
to val
. Reverting the null
check also works but unsure which is the correct solution.
Expected behavior
No errors when compiling valid code.
Steps to reproduce
See issue description.
Test case
No response
Additional comments
No response