madonoharu / tsify

A library for generating TypeScript definitions from rust code.
Apache License 2.0
300 stars 41 forks source link

FR: expand rename behaviour when only `into` / `from` + implemented with `rename_all` #51

Open joshua-auchincloss opened 7 months ago

joshua-auchincloss commented 7 months ago

Noting behaviour where:

  1. The struct has rename_all(deserialize = "...") or rename_all(serialize = "...")
  2. The tsify macro only generates either into_wasm_abi or from_wasm_abi

With the two, if the rename_all aligns with the single generated variant, one would expect the generated TS code to follow the (e.g.) + into_wasm_abi with the rename_all(serialize = "...") outputs. Based on this, hoping to submit this as a FR to add functionality to enable intrinsic renaming behaviour.

Reproducible Issue

use tsify::Tsify;
use serde::Deserialize;

#[derive(Deserialize, Tsify)]
#[tsify(into_wasm_abi)]
#[serde(rename_all(serialize = "camelCase"))
struct MyStruct {
    should_be_camel_in_ts: i32
}

Ts Outputs

interface MyStruct {
   should_be_camel_in_ts: number
}

Expected

interface MyStruct {
   shouldBeCamelInTs: number
}