Localized view macro errors + Prop autocomplete#4631
Localized view macro errors + Prop autocomplete#4631lpotthast wants to merge 60 commits intoleptos-rs:mainfrom
Conversation
…code duplications; Add comments
… special-handle Fn* bounds
…res): Fixes broken doc tests
… closures props taking parameters; Update documentation
…al Present/Absent types
…omponents; Switch back to type-inference bridge for helper/builder retrieval in view! macro
…only purpose, reducing debug-build WASM size
|
Wow! Well, the results in the screenshots certainly look great, along with the other results you've reported.
Debug build WASM size is not an issue at all. Release build WASM size would be a concern if it was affected. It sounds like you're saying it is not? Compile time in larger codebases is the other question that matters.
No worries -- sometimes it takes what it takes to get something done. I hope you'll understand it may take me a while to find time to review. Thanks so much, this looks like it could be a big improvement. For anyone else reading: I'd really appreciate help reviewing some of this. The next six weeks or so is the time of year when I have the least time, so any help would be welcome. |
…s is prefixed with `__`
# Conflicts: # leptos/src/show_let.rs
Fixes #4628
Fixes #4630
Hey @gbj,
in this branch, I tried to make errors be reported where they actually happen, so that they do not disturb a user, but instead steer them in the right direction for quickly fixing them. No error should ever span the entire view! macro. Custom messages should be emitted where possible. When multiple things are erroneous, no error should be hidden until an earlier error is resolved. The changes should be as non-breaking as possible.
(Though this could be done with a few quick "replace
quote!withquote_spanned!" and a few span re-calculations here and there... But oh boy, was I wrong. I do think there could have been a smaller/more focused change that might accomplish the same, but I had to refactor some parts to make sense of it. Sorry for the inconveniences of such large changesets! :/)Please see leptos_macro/LOCALIZED_ERRORS.md for an overview of what changed and how.
As a summary:
These macro code-gen changes add purely compile-time validation. Sadly, this comes at a slight cost of around 6.5% WASM binary size increase in debug builds. In release builds, there is no difference with main/latest on crates.io, as all new code is indeed optimized away. I don't have any more ideas on how the impact on debug builds could be reduced. But I also do think that this is an acceptable price for the gain in developer experience.
Examples:
Missing required prop:

Component requires children:

Wrong concrete prop type:

Wrong generic prop type:

Wrong children:

Autocomplete:
