Skip to content

Change Capitalize and Uncapitalize from intrinsic #42334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
5 tasks done
sno2 opened this issue Jan 14, 2021 · 2 comments
Closed
5 tasks done

Change Capitalize and Uncapitalize from intrinsic #42334

sno2 opened this issue Jan 14, 2021 · 2 comments
Labels
In Discussion Not yet reached consensus Suggestion An idea for TypeScript

Comments

@sno2
Copy link
Contributor

sno2 commented Jan 14, 2021

Suggestion

✅ Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

lib Update Request

Configuration Check

My compilation target is ES2015 and my lib is the default.

Sample Code

Inside of lib.es5.d.ts, the Capitalize and Uncapitalize types are typed as intrinsic. However, these can easily be created in regular TS with the following:

type Capitalize<S extends string> = S extends `${infer C}${infer $S}` ? `${Uppercase<C>}${$S}` : never;

type Uncapitalize<S extends string> = S extends `${infer C}${infer $S}` ? `${Lowercase<C>}${$S}` : never;
@sno2
Copy link
Contributor Author

sno2 commented Jan 14, 2021

#41283 is related.

@RyanCavanaugh RyanCavanaugh added In Discussion Not yet reached consensus Suggestion An idea for TypeScript labels Jan 14, 2021
@sno2
Copy link
Contributor Author

sno2 commented Mar 13, 2021

I don't agree with this idea anymore because TypeScript overflows with a way too little amount of characters using this method.

@sno2 sno2 closed this as completed Mar 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
In Discussion Not yet reached consensus Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants