Skip to content

Commit

Permalink
Merge pull request #7 from cwfitzgerald/byte-buf
Browse files Browse the repository at this point in the history
Support ByteBuf
  • Loading branch information
siefkenj authored Jan 13, 2024
2 parents d66f68a + 9bde380 commit dc2fc17
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tsify-macros/src/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,17 @@ impl TsType {
Self::Array(Box::new(elem))
}

"ByteBuf" => {
if cfg!(feature = "js") {
Self::Ref {
name: String::from("Uint8Array"),
type_params: vec![],
}
} else {
Self::Array(Box::new(Self::NUMBER))
}
}

"Option" if args.len() == 1 => Self::Option(Box::new(Self::from_syn_type(args[0]))),

"Result" if args.len() == 2 => {
Expand Down Expand Up @@ -769,12 +780,14 @@ mod tests {
assert_ts!(HashMap<String, i32> | BTreeMap<String, i32>, "Map<string, number>");
assert_ts!(Option<i32>, "number | undefined");
assert_ts!(Vec<Option<T>> | VecDeque<Option<T>> | LinkedList<Option<T>> | &'a [Option<T>], "(T | undefined)[]");
assert_ts!(ByteBuf, "Uint8Array");
} else {
assert_ts!((), "null");
assert_ts!(u128 | i128, "number");
assert_ts!(HashMap<String, i32> | BTreeMap<String, i32>, "Record<string, number>");
assert_ts!(Option<i32>, "number | null");
assert_ts!(Vec<Option<T>> | VecDeque<Option<T>> | LinkedList<Option<T>> | &'a [Option<T>], "(T | null)[]");
assert_ts!(ByteBuf, "number[]");
}

assert_ts!(
Expand Down

0 comments on commit dc2fc17

Please sign in to comment.