Functional Programming with Typescript — The Series

Oscar
2 min readSep 6, 2022

--

This is a series of blog posts on how to integrate functional programming principles for your application while keeping it type-safe with Typescript.

It includes a set of topics around functional programming core concepts like Pure functions and Immutability and some more advanced ones like High Order Functions and Factory Functions.

Context and Background

I’ve been working with Javascript since 2015 and started learning functional programming around 2017. At some point while learning about it, I found the amazing Composing Software: The Book written by Eric Elliott. When reading it, I felt I gain superpowers that allowed me to create flexible, scalable, and what if feels more creative/fun software.

Then after Typescript started gaining more and more traction and it looked like it would become the way to go for web applications (Node.js, React) I started looking into it.

One thing that struck me very hard when I started reading through the documentation back then, is that for every example there wasn’t anything related to Functional Programming, it was only using Classes, inheritance, and other Object Oriented Principles.

Sad that I felt that the tool was only targeted for a specific developer segment I ignored Typescript for a few years.

Everything changed in 2021 when I lead my first project and decided to use Typescript. I started by looking for ways to keep using the same functional patterns and concepts but with type safety.

I soon found out that there wasn’t much information about it so I and my team started to create types and come up with ways to support the various FP patterns like High Order Functions and Currying.

Content

This series of posts is to illustrate the different ways of applying Functional Programming principles with Typescript and doing it in a practical way where the developers can feel familiar with the patterns and use cases

I have included the topics I feel have more day-to-day usage. But I understand that there are many more that can be implemented and I might come back to add more posts later on.

Appreciation

On a less serious note, I want to say thanks to everyone that has taken the time to read through the posts and I hope that everyone can find it helpful!

If you want to have a chat, you can reach me at: oscar-rreyes1@hotmail.com. Cheers!

--

--