Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ where
}
}

impl<T: Tsify> From<Ts<T>> for JsValue {
fn from(value: Ts<T>) -> Self {
value.js_value()
}
}

impl<T: Tsify> fmt::Debug for Ts<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("Ts").finish()
Expand Down
6 changes: 6 additions & 0 deletions tests-e2e/reference_output/test6/test6.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ export function accept_point_vec(point: Point[]): void;

export function return_point(point: Point): Point;

export function return_point_async(point: Point): Promise<Point>;

export function return_point_option_async(point: Point): Promise<Point | undefined>;

export function return_point_result_async(point: Point): Promise<Point>;

export function return_point_vec(): Point[];
17 changes: 17 additions & 0 deletions tests-e2e/test6/entry_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,23 @@ pub fn return_point(point: &Ts<Point>) -> Ts<Point> {
#[wasm_bindgen]
pub async fn accept_point_ref_async(point: &Ts<Point>) {}

// Async fns return through `IntoJsResult`; the bare, `Result`, and `Option`
// shapes below each require `Ts<T>: Into<JsValue>` via a distinct impl path.
#[wasm_bindgen]
pub async fn return_point_async(point: &Ts<Point>) -> Ts<Point> {
point.clone()
}

#[wasm_bindgen]
pub async fn return_point_result_async(point: Ts<Point>) -> Result<Ts<Point>, JsError> {
Ok(point)
}

#[wasm_bindgen]
pub async fn return_point_option_async(point: &Ts<Point>) -> Option<Ts<Point>> {
Some(point.clone())
}

#[wasm_bindgen]
pub fn accept_point_vec(point: Vec<Ts<Point>>) {}

Expand Down
Loading