Type Aliases for String manipulation

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 ๐Ÿ”ฅ


Let's chat and have fun ๐Ÿง‘โ€๐Ÿ’ป๐Ÿ‘ฉโ€๐Ÿ’ป

No more often than once a week I write ๐Ÿ“„ about TypeScript ๐Ÿ’ช, video playback ๐Ÿ“บ and frontend related topics. You can unsubscribe in any time โ†˜๏ธ

ยฉ 2021, Built with Gatsby