#Case conversion issue with data passed from Rust -> TS.

9 messages · Page 1 of 1 (latest)

vernal quail
#

Hey I'm using tauri and I had a doubt regarding the ipc data passed between rust and ts.
So the data passed by rust is in snake_case. However it feels wrong to write snake_case in ts. So I wrote a function to convert snake_case to camelCase. However ts complains about the types that I used and there is always a swiggly line over the function when called (I'm an ametuer in ts, just learning).

How did you guys deal with the case conversion issue?

stable nacelle
#

well, the data is converted to camelCase by default

#

at least the top level command arguments
Edit: For nested structs in args, or structs in general that you return from commands you'll have to tell serde about the case conversation. Then you don't have to worry about that on the ts side.

#

apart from that, what exactly a swiggly line means depends on your IDE, often it's just the spell checker, so if you have a bit more info on that please share it with us

vernal quail
#

How do I go about doing that? is it in the docs?

#

I think I figured it out

#

Added #[serde(rename_all = "camelCase")]

stable nacelle
#

yep