Fix nullable union types
@@ -549,7 +549,12 @@ impl<'a> IdlType<'a> {
},
IdlType::Enum(name) => Some(ident_ty(rust_ident(camel_case_ident(name).as_str()))),
- IdlType::Nullable(idl_type) => Some(option_ty(idl_type.to_syn_type(pos)?)),
+ IdlType::Nullable(idl_type) => {
+ match **idl_type {
+ IdlType::Union(..) => idl_type.to_syn_type(pos),
+ _ => Some(option_ty(idl_type.to_syn_type(pos)?))
+ }
+ },
IdlType::FrozenArray(_idl_type) => None,
IdlType::Sequence(_idl_type) => None,
IdlType::Promise(_idl_type) => {
@@ -563,10 +568,10 @@ impl<'a> IdlType<'a> {
}
IdlType::Record(_idl_type_from, _idl_type_to) => None,
IdlType::Union(_idl_types) => {
- // Handles union types in all places except operation argument types
+ // Handles union types in all places except operation argument types.
+ // Currently treats them as any type.
// TODO: add better support for union types here?
- let path = vec![rust_ident("wasm_bindgen"), rust_ident("JsValue")];
- Some(leading_colon_path_ty(path))
+ IdlType::Any.to_syn_type(pos)
},
IdlType::Any => {
