Browse Source

fix: Support `Input::<..>` style to for generic components

before that, we accepted this style `Input<..>` but to be consistent
with Rust syntax this is dropped now.

> For reference, the two ways of specifying explicit type parameters in
> Rust are:
> // for functions
> let _ = foo::<MyType>();
>
> // for structs
> let _ = Foo::<MyType> { ... };
>
> by @jkelleyrtp
Muhannad Alrusayni 3 năm trước cách đây
mục cha
commit
690efade88

+ 1 - 1
packages/core-macro/src/rsx/component.rs

@@ -141,7 +141,7 @@ impl ToTokens for Component {
             }
             None => {
                 let mut toks = match prop_gen_args {
-                    Some(gen_args) => quote! { fc_to_builder::#gen_args(#name) },
+                    Some(gen_args) => quote! { fc_to_builder #gen_args(#name) },
                     None => quote! { fc_to_builder(#name) },
                 };
                 for field in &self.body {

+ 3 - 3
packages/core-macro/src/rsx/node.rs

@@ -65,10 +65,10 @@ impl Parse for BodyNode {
             // ::component ()
             // crate::component{}
             // crate::component()
-            // Input<'_, String> {}
-            // crate::Input<'_, i32> {}
+            // Input::<InputProps<'_, i32> {}
+            // crate::Input::<InputProps<'_, i32> {}
             if body_stream.peek(token::Brace) || body_stream.peek(token::Paren) {
-                // this syntax is not allowd:
+                // NOTE: this syntax is not allowd:
                 // Div () -> comp
                 if path.segments.len() == 1 && body_stream.peek(token::Paren) {
                     let com_ident = &path.segments.iter().next().unwrap().ident;