The problem of switch not being an expression has _always_ bugged me.

I would not recommend TypeScript for this type of context-switching. It either wouldn’t work, or be excruciatingly painful. In fact, TypeScript (and Flow) don’t work so well for functional programming.

For a statically typed FP experience, I’d recommend just using a proper statically typed FP language (e.g, PureScript, ClojureScript, Fable, Elm, Reason). You get better ergonomy and more idiomatic code than our little hacks. ☺

Like what you read? Give Hajime Yamasaki Vukelic a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.