maciejhirsz / kobold

Easy declarative web interfaces.
https://docs.rs/kobold/
Mozilla Public License 2.0
388 stars 7 forks source link

Hint everything #49

Closed maciejhirsz closed 1 year ago

maciejhirsz commented 1 year ago

image

Continuation of the work started in #46, this PR adds hints to all DOM element attributes, including those that are statically compiled into JS. This is done by generating dead code such as:

#[allow(unused_variables)]
{
   fn _hint_0(href: impl Attribute<Href>) {}
}

The param of the hint function (href here) is spanned to the attribute in the view! macro, effectively tricking rust-analyzer into providing a hint for the type (even if the value is never instantiated in Rust to begin with).