sindresorhus/type-fest
View on GitHubSnakeCaseProperties doesn't handle PascalCase and UPPERCASE
Open
#223 opened on Jun 26, 2021
bugcomponent:casinghelp wanted
Repository metrics
- Stars
- (12,328 stars)
- PR merge metrics
- (Avg merge 3d 5h) (11 merged PRs in 30d)
Description
I have a type with PascalCase and a few uppercase properties, e.g.
Identifiers: {
MarketplaceASIN: {
MarketplaceId: string;
ASIN: string;
},
}
SnakeCasedPropertiesDeep turns this into:
_identifiers: {
_marketplace_a_s_i_n: {
_marketplace_id: string;
_a_s_i_n: string;
};
};
It doesn't handle the cases where the property starts with an uppercase and where the property contains multiple uppercase letters in a row.
I could overcome the first issue by using CamelCasedPropertiesDeep first.
What I would expect is:
identifiers: {
marketplace_asin: {
marketplace_id: string;
asin: string;
};
};
During runtime I use lodash's https://lodash.com/docs/4.17.15#snakeCase method. Is there a way to use the same method for the type?