|
Hi there, I'm working on serializing { [key in bigint]?: Array<CoolType> }However, I would prefer to use number for the keys instead of bigint. I attempted to annotate the map directly with a custom type, but encountered an issue where CoolType is not imported correctly. Here's what I tried: #[derive(Debug, Clone, Serialize, TS)]
#[ts(export)]
pub struct AwesomeStruct {
#[ts(type = "{ [key in number]?: Array<CoolType> }")]
pub cool_types: HashMap<i64, Vec<CoolType>>,
}The problem with this approach is that What is the recommended way to annotate a type within a type? |
Answered by
NyxCode
Oct 25, 2024
Replies: 1 comment 1 reply
|
Hey! |
1 reply
Answer selected by
hongyilyu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey!
I think
#[ts(as = "HashMap<i32, Vec<CoolType>>")]should work.