-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add generic type hints to boxed hooks (#3633)
When using complex type constructs in a boxed hook, the compiler could get confused and request a type hint on the call to the inner function. This adds all generic types of the outer hook function as explicit arguments to the call of the inner function. * Add generic types to boxed hooks * Create failing test --------- Co-authored-by: Michael Meyer <[email protected]>
- Loading branch information
Showing
2 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/yew-macro/tests/hook_attr/hook-trait-item-pass.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use std::marker::PhantomData; | ||
|
||
pub struct QueryState<T> { | ||
p: PhantomData<T> | ||
} | ||
|
||
pub trait MyTrait { | ||
type Associated; | ||
} | ||
|
||
|
||
#[yew::hook] | ||
pub fn use_query_state<Props>( | ||
selector: impl yew::html::IntoPropValue<bool>, | ||
) -> QueryState<Props::Associated> | ||
where | ||
Props: MyTrait, | ||
{ | ||
QueryState::<Props::Associated> { p: PhantomData::<Props::Associated> } | ||
} | ||
|
||
fn main() {} |