fix(napi-derive-backend): do not unwrap Option value in object getter if the type of field is Option<T>

This commit is contained in:
LongYinan 2021-12-02 15:47:59 +08:00
parent d58e488fa2
commit 6d4b4af36f
No known key found for this signature in database
GPG key ID: C3666B7FC82ADAD7
7 changed files with 55 additions and 4 deletions
crates/napi/src/bindgen_runtime/js_values

View file

@ -35,7 +35,7 @@ impl Object {
let ty = type_of!(self.0.env, ret)?;
Ok(if ty == ValueType::Undefined {
Ok(if ty == ValueType::Undefined || ty == ValueType::Null {
None
} else {
Some(V::from_napi_value(self.0.env, ret)?)