sindresorhus/type-fest

SnakeCaseProperties doesn't handle PascalCase and UPPERCASE

Open

#223 创建于 2021年6月26日

在 GitHub 查看
 (2 评论) (0 反应) (0 负责人)TypeScript (471 fork)batch import
bugcomponent:casinghelp wanted

仓库指标

Star
 (12,328 star)
PR 合并指标
 (平均合并 3天 5小时) (30 天内合并 11 个 PR)

描述

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?

贡献者指南