mirror of
https://github.com/napi-rs/napi-rs.git
synced 2026-02-01 16:41:24 +00:00
Fix TypeScript definition for async_fail_in_to_napi_value
Co-authored-by: Brooooooklyn <3468483+Brooooooklyn@users.noreply.github.com>
This commit is contained in:
parent
d57c03fab8
commit
48853b1fb8
@ -388,7 +388,14 @@ export declare function arrayParams(arr: Array<number>): number
|
||||
|
||||
export declare function asyncBufferToArray(buf: ArrayBuffer): Array<number>
|
||||
|
||||
export declare function asyncFailInToNapiValue(): Promise<FailToNapiValue>
|
||||
/**
|
||||
* Test function that returns a type which fails during to_napi_value conversion.
|
||||
* This tests that errors from ToNapiValue::to_napi_value properly reject the promise
|
||||
* instead of throwing synchronously.
|
||||
*
|
||||
* The promise will always be rejected with "Fail in to_napi_value" error.
|
||||
*/
|
||||
export declare function asyncFailInToNapiValue(): Promise<never>
|
||||
|
||||
export declare function asyncMultiTwo(arg: number): Promise<number>
|
||||
|
||||
|
||||
@ -86,6 +86,9 @@ pub fn extends_javascript_error(env: Env, error_class: Function<String>) -> Resu
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// A struct that intentionally fails during conversion to JS value.
|
||||
/// Used to test error handling in async functions when ToNapiValue::to_napi_value returns an error.
|
||||
/// Note: This struct is not exported to JS and cannot be used directly from JavaScript.
|
||||
pub struct FailToNapiValue;
|
||||
|
||||
impl ToNapiValue for FailToNapiValue {
|
||||
@ -94,7 +97,12 @@ impl ToNapiValue for FailToNapiValue {
|
||||
}
|
||||
}
|
||||
|
||||
#[napi]
|
||||
/// Test function that returns a type which fails during to_napi_value conversion.
|
||||
/// This tests that errors from ToNapiValue::to_napi_value properly reject the promise
|
||||
/// instead of throwing synchronously.
|
||||
///
|
||||
/// The promise will always be rejected with "Fail in to_napi_value" error.
|
||||
#[napi(ts_return_type = "Promise<never>")]
|
||||
pub async fn async_fail_in_to_napi_value() -> FailToNapiValue {
|
||||
FailToNapiValue
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user