Skip to content

Commit 0faa978

Browse files
committed
fix(oxfmt): JsFormatEmbeddedCb types (#16324)
1 parent d3e4354 commit 0faa978

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

apps/oxfmt/src-js/bindings.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
*
1010
* Returns `true` if formatting succeeded without errors, `false` otherwise.
1111
*/
12-
export declare function format(args: Array<string>, formatEmbeddedCb: JsFormatEmbeddedCb): Promise<boolean>
12+
export declare function format(args: Array<string>, formatEmbeddedCb: (tagName: string, code: string) => Promise<string>): Promise<boolean>

apps/oxfmt/src/main_napi.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ use crate::{
2828
#[expect(clippy::allow_attributes)]
2929
#[allow(clippy::trailing_empty_array, clippy::unused_async)] // https://github.com/napi-rs/napi-rs/issues/2758
3030
#[napi]
31-
pub async fn format(args: Vec<String>, format_embedded_cb: JsFormatEmbeddedCb) -> bool {
31+
pub async fn format(
32+
args: Vec<String>,
33+
#[napi(ts_arg_type = "(tagName: string, code: string) => Promise<string>")]
34+
format_embedded_cb: JsFormatEmbeddedCb,
35+
) -> bool {
3236
format_impl(args, format_embedded_cb).await.report() == ExitCode::SUCCESS
3337
}
3438

0 commit comments

Comments
 (0)