Open jonahsnider opened 2 years ago
If both methods should be added, I propose adding endsWith
, startsWtih
, padEnd
, padStart
, repeat
, trimEnd
, trimStart
, trim
and so on. https://github.com/microsoft/TypeScript/blob/main/tests/cases/conformance/types/literal/templateLiteralTypes1.ts
How would using this method over String.prototype.toLowerCase()
improve your code? Strict types are great, but they got to have a purpose.
Personally I don't have any use case for either of the proposed case functions. However there are surely developers who could benefit from using one of them instead of just asserting the type after using the built-in method.
Let's keep this open for more feedback. I would like to see more realistic use-cases.
String.prototype.toLowerCase()
andString.prototype.toUpperCase()
are typed as returningstring
. This doesn't make use of the relatively recently addedUppercase<T>
andLowercase<T>
types in TypeScript.I propose adding two functions to this library: