Intrinsic string manipulation types in TypeScript
14 May 2021
Today we discuss Capitalize
If you need to make first character in a string uppercase, that's the challenge you look for.
Let's have a look 👀
Type aliases for String manipulation
Since TypeScript 4.1 we have type aliases Uppercase
, Lowercase
, Capitalize
and Uncapitalize
.
Knowing how to iterate over a string let's find first element and make it uppercase:
We inferred First
, made it uppercase with type alias Uppercase
. In case of empty string we return itself without any update.
Tests and examples are available in Playground
Have a wonderful Friday 🔥
typescript