<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Lennard Schutter on Medium]]></title>
        <description><![CDATA[Stories by Lennard Schutter on Medium]]></description>
        <link>https://medium.com/@lennardschutter?source=rss-b55f95705e93------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QNYj2qpyy57n4YuPZZrLaw.jpeg</url>
            <title>Stories by Lennard Schutter on Medium</title>
            <link>https://medium.com/@lennardschutter?source=rss-b55f95705e93------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 17:41:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lennardschutter/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Exhaustive reducers with Typescript]]></title>
            <link>https://medium.com/@lennardschutter/exhaustive-reducers-with-typescript-aa7f9b888974?source=rss-b55f95705e93------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa7f9b888974</guid>
            <category><![CDATA[reducer]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[redux]]></category>
            <dc:creator><![CDATA[Lennard Schutter]]></dc:creator>
            <pubDate>Thu, 11 Oct 2018 01:24:08 GMT</pubDate>
            <atom:updated>2018-10-11T05:11:54.346Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GP_BjqHD0s4D3On2f1pOQA.png" /></figure><p>As you start writing your reducers in Typescript you might run into the scenario where you want to make your reducer functions exhaustive. I’d normally make a function exhaustive with a vanilla exhaustive check.</p><p>Let’s say you’ve got a simple counterReducer where your CounterAction is an union between an IncrementAction, a DecrementAction and a ResetAction . However, you’ve forgotten to implement the last action.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1e74ff0f9240c559e5dacef99934761/href">https://medium.com/media/f1e74ff0f9240c559e5dacef99934761/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e7ab27415fe9ebfd8cd0e0e3dd2c3f86/href">https://medium.com/media/e7ab27415fe9ebfd8cd0e0e3dd2c3f86/href</a></iframe><p>Without an exhaustive check, your reducer would just return the state and you would not know about it until runtime when your state is not updating. Adding a simple exhaustive check will tell us during compilation that we’ve forgotten one of the cases.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b391f93ff25bb16ce9eedfe2b80183d7/href">https://medium.com/media/b391f93ff25bb16ce9eedfe2b80183d7/href</a></iframe><p>Above is a simple exhaustive check. It works by validating the arguments passed are of type never, which of course, should never happen since our code is exhaustive. In this check, nothing is returned, but you could also throw an error here.</p><p>After implementing the exhaustive check you can now see that the compiler is showing an error (Argument of type ‘ResetAction’ is not assignable to parameter of type ‘never’.) on our action. This is because our switch has a path that is not handled, the ResetAction.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/53e3a560257ce0c9217aae1b2bc1fa7d/href">https://medium.com/media/53e3a560257ce0c9217aae1b2bc1fa7d/href</a></iframe><p>You will have to explicitly code for each path that your switch might have to handle. After implementing the ResetAction you can see the error is gone since all code paths are accounted for.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e8616b634750537f38deabbb07b3cb85/href">https://medium.com/media/e8616b634750537f38deabbb07b3cb85/href</a></iframe><p>So in short. Adding an exhaustive check to your reducer will ensure all your actions are handled, which reducers the chance of runtime issues. I hope you’ve enjoyed this article!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa7f9b888974" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>