microsoft / microsoft/TypeScript
Uncapitalize seems to not working within a type helper
Open
Nobody has claimed this yet.
Bug
Domain: Literal Types
Help Wanted
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked TypeScript Playground reproduction and compare the inferred results for CamelCase1, CamelCase2, and Uncapitalize. Investigate the type-system behavior behind intrinsic string manipulation types; the issue is done when the reproduced Uncapitalize<CamelCase2<"FOOBAR">> result is lowercase as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100