tsync icon indicating copy to clipboard operation
tsync copied to clipboard

Wrong value is exported if hex number is used

Open jonatino opened this issue 8 months ago • 1 comments

#[derive(Serialize_repr)]
#[repr(u16)]
#[tsync]
pub enum KeyCode {
    Space = 0x0020,
    Apostrophe = 0x0027,
    Comma = 0x002c,
    Minus = 0x002d,
}

exports as

KeyCode = {
    Space: 0,
    Apostrophe: 1,
    Comma: 2,
    Minus: 3
}

jonatino avatar May 17 '25 06:05 jonatino

the relevant code snippet for this issue seems to be:

https://github.com/Wulf/tsync/blob/08e14c04e439ecd1863526b11dc7b8c8d22d9a52/src/to_typescript/enums.rs#L142-L158

AnthonyMichaelTDM avatar Oct 30 '25 23:10 AnthonyMichaelTDM

It is specifically because String::parse::() does not support hexadecimal numbers

AskSkivdal avatar Dec 12 '25 16:12 AskSkivdal