Aleph-Alpha/ts-rs

bug: Using `#[ts(rename_all = "...")]` `snake_case`, `SCREAMING_SNAKE_CASE` and `kebab-case` is not compatible with serde

escritorio-gustavo opened this issue · 0 comments

Describe the bug
A few months ago, issue #165 reported inconsistencies in the implementation of inflector's camelCase in comparison with serde's. It turns out its snake_case implementation is also not consistent, which affects snake_case, SCREAMING_SNAKE_CASE (a.k.a. snake_case.to_ascii_uppercase()) and kebab-case (a.k.a. snake_case.replace('_', "-")). Also, we're missing SCREAMING-KEBAB-CASE

To Reproduce

#[derive(TS, Default, serde::Serialize)]
#[ts(export, export_to = "struct_rename/", rename_all = "kebab-case")]
#[serde(rename_all = "kebab-case")]
struct RenameAllScreamingKebab {
    crc32c_hash: i32,
    some_field: i32,
    some_other_field: i32,
}

Expected behavior

export type RenameAllScreamingKebab = {
    "crc32c-hash": number,
    "some-field": number,
    "some-other-field": number,
};

Actual behavior

export type RenameAllScreamingKebab = {
    "crc-3-2c-hash": number,
    "some-field": number,
    "some-other-field": number,
};