Allow stylex.create
nested within TS namespaces (and more?)
#829
Labels
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
Discussed in #827
Originally posted by zaydek December 30, 2024
I love using TS namespaces to create conceptual boundaries so it's easier to reason about what different chunks of my code do. Like a
Button
namespace so I can aggregate relevant variables and components for buttons. One thing I've noticed is that StyleX is incompatible with TS namespaces so I can't do something likenamespace Foo { const styles = stylex.create({ ... }); }
.I believe what's going on is that TS namespaces are syntax sugar for objects and therefore it may be impossible to add support for this. That being said, is there a way for me to colocate styles behind something like a namespace so I can do something like the following in the future?
I know I can simply create boundary lines using files but I find namespaces allow me to do the job of several files in one file, but when it comes to StyleX APIs, it breaks this convention and I need to prefix styles, which is OK but slightly annoying.
Any ideas or recommendations?
Here is an example of some code where I'd love to have the ability to nest the styles under the namespace instead of prefixing the styles name:
The text was updated successfully, but these errors were encountered: