From 1cd5401ad72e7cce5b95942cbce1ab00a029a370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Deng=20=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90?= Date: Mon, 26 Aug 2024 12:51:19 +0800 Subject: [PATCH] fix(wasm): respect camelCase (#5213) --- crates/oxc_wasm/src/lib.rs | 6 +----- crates/oxc_wasm/src/options.rs | 16 +++++++++------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/crates/oxc_wasm/src/lib.rs b/crates/oxc_wasm/src/lib.rs index adcaed21f..a401f9eee 100644 --- a/crates/oxc_wasm/src/lib.rs +++ b/crates/oxc_wasm/src/lib.rs @@ -29,6 +29,7 @@ use crate::options::{ #[wasm_bindgen(getter_with_clone)] #[derive(Default, Tsify)] +#[serde(rename_all = "camelCase")] pub struct Oxc { source_text: String, @@ -45,23 +46,18 @@ pub struct Oxc { pub symbols: JsValue, #[wasm_bindgen(readonly, skip_typescript, js_name = "scopeText")] - #[serde(rename = "scopeText")] pub scope_text: String, #[wasm_bindgen(readonly, skip_typescript, js_name = "codegenText")] - #[serde(rename = "codegenText")] pub codegen_text: String, #[wasm_bindgen(readonly, skip_typescript, js_name = "formattedText")] - #[serde(rename = "formattedText")] pub formatted_text: String, #[wasm_bindgen(readonly, skip_typescript, js_name = "prettierFormattedText")] - #[serde(rename = "prettierFormattedText")] pub prettier_formatted_text: String, #[wasm_bindgen(readonly, skip_typescript, js_name = "prettierIrText")] - #[serde(rename = "prettierIrText")] pub prettier_ir_text: String, comments: Vec, diff --git a/crates/oxc_wasm/src/options.rs b/crates/oxc_wasm/src/options.rs index 3ada7e35c..20078e555 100644 --- a/crates/oxc_wasm/src/options.rs +++ b/crates/oxc_wasm/src/options.rs @@ -1,7 +1,9 @@ +use tsify::Tsify; use wasm_bindgen::prelude::*; #[wasm_bindgen] -#[derive(Default, Clone, Copy)] +#[derive(Default, Clone, Copy, Tsify)] +#[serde(rename_all = "camelCase")] pub struct OxcRunOptions { syntax: bool, lint: bool, @@ -51,22 +53,22 @@ impl OxcRunOptions { self.format = yes; } - #[wasm_bindgen(getter)] + #[wasm_bindgen(getter = "prettierFormat")] pub fn prettier_format(&self) -> bool { self.prettier_format } - #[wasm_bindgen(setter)] + #[wasm_bindgen(setter = "prettierFormat")] pub fn set_prettier_format(&mut self, yes: bool) { self.prettier_format = yes; } - #[wasm_bindgen(getter)] + #[wasm_bindgen(getter = "prettierIr")] pub fn prettier_ir(&self) -> bool { self.prettier_ir } - #[wasm_bindgen(setter)] + #[wasm_bindgen(setter = "prettierIr")] pub fn set_prettier_ir(&mut self, yes: bool) { self.prettier_ir = yes; } @@ -81,12 +83,12 @@ impl OxcRunOptions { self.transform = yes; } - #[wasm_bindgen(getter)] + #[wasm_bindgen(getter = "typeCheck")] pub fn type_check(&self) -> bool { self.type_check } - #[wasm_bindgen(setter)] + #[wasm_bindgen(setter = "typeCheck")] pub fn set_type_check(&mut self, yes: bool) { self.type_check = yes; }