Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
escritorio-gustavo opened this issue Apr 5, 2024 · 0 comments · Fixed by #298
Labels
bug Something isn't working

Comments

@escritorio-gustavo
Copy link
Contributor

escritorio-gustavo commented Apr 5, 2024

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,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant