let func: napi::bindgen_prelude::Function<{{ args_tuple_ty }}, napi::bindgen_prelude::Unknown> = match self.inner.get_named_property("{{ method_name }}") {
    Ok(f) => f,
{% if has_default_impl %}
    // Method has a default impl on the Rust trait — treat missing JS property as a no-op
    // (the foreign object opted out of overriding it). Falls back to Default::default().
    Err(_) => return {% if has_error %}Ok(Default::default()){% else %}Default::default(){% endif %},
{% elif has_error %}
    Err(e) => return Err({{ error_lookup }}),
{% else %}
    Err(_) => return Default::default(),
{% endif %}
};

{% if empty_args %}
let result = func.call(());
{% else %}
let result = func.call(napi::bindgen_prelude::FnArgs::from({{ tuple_args }}));
{% endif %}

{% if has_error %}
match result {
    Err(e) => Err({{ error_call }}),
    Ok(val) => {
        // Convert JS value to Rust type via string coercion
        let s = val.coerce_to_string()
            .and_then(|s| s.into_utf8())
            .and_then(|s| s.into_owned())
            .map_err(|e| {{ error_coercion }})?;
        match s.as_str() {
            // null/empty is a protocol error for Result-returning methods: the JS
            // implementation must always return a serialisable value, never null.
            // Avoid requiring Default on the return type (excluded types like
            // InternalDocument do not implement Default).
            "" | "null" => Err({{ error_parse }}),
            _ => {
                serde_json::from_str::<_>(&s).map_err(|_| {{ error_parse }})
            }
        }
    }
}
{% else %}
match result {
    Err(_) => Default::default(),
    Ok(val) => {
        // Convert JS value to Rust type via string coercion
        let s = val.coerce_to_string()
            .and_then(|s| s.into_utf8())
            .and_then(|s| s.into_owned())
            .unwrap_or_default();
        match s.as_str() {
            "" | "null" => Default::default(),
            _ => serde_json::from_str::<_>(&s).unwrap_or_default()
        }
    }
}
{% endif %}
