Type Aliases for String manipulation

Example of Capitalize use
Example of Capitalize use

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 🔥

Alexey Berezin profile image

Written by Alexey Berezin who loves London 🏴󠁧󠁢󠁥󠁮󠁧󠁿, players ⏯ and TypeScript 🦺 Follow me on Twitter