-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Literal TypesUnit types including string literal types, numeric literal types, Boolean literals, null, undefinedUnit types including string literal types, numeric literal types, Boolean literals, null, undefinedHelp WantedYou can do thisYou can do this
Milestone
Description
Bug Report
🔎 Search Terms
Uncapitalize
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about Uncapitalize
⏯ Playground Link
Playground link with relevant code
💻 Code
type CamelCase1<
S extends string,
L extends string = Lowercase<S>,
Res extends string = ""
> = L extends ""
? Uncapitalize<Res>
: L extends `${infer H}_${infer T}`
? CamelCase1<never, T, `${Res}${Capitalize<H>}`>
: CamelCase1<never, "", `${Res}${Capitalize<L>}`>;
type test1 = CamelCase2<"FOOBAR">
// ^? type test1 = "Foobar"
type CamelCase2<
S extends string,
L extends string = Lowercase<S>,
Res extends string = ""
> = L extends ""
? Res
: L extends `${infer H}_${infer T}`
? CamelCase2<never, T, `${Res}${Capitalize<H>}`>
: CamelCase2<never, "", `${Res}${Capitalize<L>}`>;
type test2 = Uncapitalize<CamelCase2<"FOOBAR">>
// ^? type test2 = "foobar"
🙁 Actual behavior
First letter is uppercase
🙂 Expected behavior
First letter should be lowercase
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Literal TypesUnit types including string literal types, numeric literal types, Boolean literals, null, undefinedUnit types including string literal types, numeric literal types, Boolean literals, null, undefinedHelp WantedYou can do thisYou can do this