-
-
Notifications
You must be signed in to change notification settings - Fork 948
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
Simplify and fix some issues with #[component]
macro
#2289
Simplify and fix some issues with #[component]
macro
#2289
Conversation
Expanding the component name to a struct will cause lints on any components that use the |
That's the point, since the convention is upper camel case and not snake case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the fact that we're trimming the fat in this module - I was very confused by the complexity of it all last time I was digging around here.
Can we keep support for lowercase components? They're basically our unofficial syntax for wrapped web components. IE you'd wrap a stringly typed kebab-case-element {} with a strongly_typed_element {}.
We don't do anything differently with codegen there, per se, but it's a decent heuristic when glancing at code as to why those components are different.
Done. I just want to point out that they're definitely "supported", they will just trigger a warning (which you can easily suppress with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewing this now, sorry for the wait.
We want to keep lowercase component support, but also allow the new deconstructed props syntax.
Also I think keeping the extra props doc is nice - it helps with discovery on optional fields.
component.rs
file + the 130 line long creatively namedutils.rs
file), which wasn't even being used!! This is the doc building that I introduced in 1563, and I'm sorry for introducing it. It's completely unnecessary because people can simply view the props struct through theprops
argument, and I don't know how it even got merged. Anyway, since then there have been some changes, and the original features made in 1563 just didn't work. I tested it out and the macro simply would not build any docs. So there was a bunch of useless code, technically being used at compilation, but not being used at runtime. Or maybe it was being used somehow, slowing down compilation but not producing any results.#[allow(non_snake_case)]
for the entire function, including the body, which would silence other stuff like variables (and also wouldn't make the compiler prefer camel case). This PR makes it so that the macro only changes case lints for the function identifier.fn Navbar(NavbarProps { title }: NavbarProps)
). This was previously being parsed incorrectly and the macro just wouldn't compile. I noticed this was used a lot in Freya which is probably why Freya doesn't use the#[component]
macro, instead opting for putting#[allow(non_snake_case)]
everywhere (which, as mentioned, is incorrect because it silences warnings of other identifiers).