microsoft / microsoft/TypeScript
String case change methods should return intrinsic string manipulation types
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
lib Update Request
Configuration Check
My compilation target is ES2018 and my lib is ["ES2016", "dom"].
Missing / Incorrect Imprecise Definitions
At least toUpperCase and toLowerCase methods on String, maybe/probably also the Locale versions?
Sample Code
type LittleT = "t" | "tt";
type BigT = Uppercase<LittleT>;
declare const smol: LittleT;
const big: BigT = smol.toUpperCase(); // err, string is not assignable to "T" | "TT
Documentation Link
https://tc39.es/ecma262/#sec-string.prototype.tolowercase
Note
I'm not sure about the Locale versions of these methods because I don't know what algorithm the "intrinsic" Uppercase<T> / Lowercase<T> helper types are required to follow. (Do we need separate LocaleUppercase / LocaleLowercase helpers?)
Also worth mentioning: I think what I'm looking for is a return type of e.g. Uppercase<this>, which shouldn't have an impact on non-literal string types because Uppercase<string> is just string.
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 ES2016 library declarations for String and the existing Uppercase and Lowercase intrinsic types. Check the sample against the requested return types, then investigate whether the locale variants require separate handling; done means the literal-string case is represented without changing the behavior of string.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100