tsify
tsify copied to clipboard
Bug: Fields starting with numeric literal need to be quoted
Input
use serde::{Serialize, Deserialize};
use tsify::Tsify;
#[derive(Serialize, Deserialize, Tsify)]
#[tsify(from_wasm_abi, into_wasm_abi)]
pub struct OneX {
#[serde(rename = "1x")]
pub one_x: f64;
}
Output
export interface One {
1x: number
}
Expected
1x
needs to be quoted
export interface One {
"1x": number
}
This isn't just for numeric fields but anything that's a legal json property name but not a legal typescript interface field name. I'm running into this a lot trying to tsify a language library written in rust, which exposes syntax tree functionality.
For example, properties with these names need to be quoted too:
-
!
-
!=
-
==
-
<=
-
>=
- and lots more
I think the linked PR satisfies all my requirements though, it'd be great if we could get that merged