Skip to content

Commit 75ac7ca

Browse files
committed
Fix nullable union types
1 parent ff516d0 commit 75ac7ca

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

crates/webidl/src/idl_type.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,12 @@ impl<'a> IdlType<'a> {
549549
},
550550
IdlType::Enum(name) => Some(ident_ty(rust_ident(camel_case_ident(name).as_str()))),
551551

552-
IdlType::Nullable(idl_type) => Some(option_ty(idl_type.to_syn_type(pos)?)),
552+
IdlType::Nullable(idl_type) => {
553+
match **idl_type {
554+
IdlType::Union(..) => idl_type.to_syn_type(pos),
555+
_ => Some(option_ty(idl_type.to_syn_type(pos)?))
556+
}
557+
},
553558
IdlType::FrozenArray(_idl_type) => None,
554559
IdlType::Sequence(_idl_type) => None,
555560
IdlType::Promise(_idl_type) => {
@@ -563,10 +568,10 @@ impl<'a> IdlType<'a> {
563568
}
564569
IdlType::Record(_idl_type_from, _idl_type_to) => None,
565570
IdlType::Union(_idl_types) => {
566-
// Handles union types in all places except operation argument types
571+
// Handles union types in all places except operation argument types.
572+
// Currently treats them as any type.
567573
// TODO: add better support for union types here?
568-
let path = vec![rust_ident("wasm_bindgen"), rust_ident("JsValue")];
569-
Some(leading_colon_path_ty(path))
574+
IdlType::Any.to_syn_type(pos)
570575
},
571576

572577
IdlType::Any => {

0 commit comments

Comments
 (0)