<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: i-am-killvish</title>
    <description>The latest articles on DEV Community by i-am-killvish (@iamkillvish).</description>
    <link>https://dev.to/iamkillvish</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3896833%2F6855fff4-8708-4764-9354-c9c245af8018.png</url>
      <title>DEV Community: i-am-killvish</title>
      <link>https://dev.to/iamkillvish</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/iamkillvish"/>
    <language>en</language>
    <item>
      <title>Why `.filter(Boolean)` Doesn't Narrow Types in TypeScript (and how I built an AST fixer for it)</title>
      <dc:creator>i-am-killvish</dc:creator>
      <pubDate>Thu, 14 May 2026 01:09:00 +0000</pubDate>
      <link>https://dev.to/iamkillvish/why-filterboolean-doesnt-narrow-types-in-typescriptand-how-i-built-an-ast-fixer-for-it-3ijh</link>
      <guid>https://dev.to/iamkillvish/why-filterboolean-doesnt-narrow-types-in-typescriptand-how-i-built-an-ast-fixer-for-it-3ijh</guid>
      <description>&lt;p&gt;One TypeScript behavior that confused me for a long time was this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;values&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;values&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At runtime, this works perfectly.&lt;/p&gt;

&lt;p&gt;But TypeScript may still complain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'v' is possibly 'undefined'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At first glance, this feels wrong.&lt;/p&gt;

&lt;p&gt;We already filtered the array.&lt;br&gt;
Why is TypeScript still acting like &lt;code&gt;undefined&lt;/code&gt; can exist?&lt;/p&gt;


&lt;h1&gt;
  
  
  The Important Thing to Understand
&lt;/h1&gt;

&lt;p&gt;TypeScript does not deeply analyze what &lt;code&gt;Boolean()&lt;/code&gt; actually does.&lt;/p&gt;

&lt;p&gt;Instead, TypeScript mostly relies on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;control-flow analysis&lt;/li&gt;
&lt;li&gt;recognized syntax patterns&lt;/li&gt;
&lt;li&gt;explicit type predicates&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So when you write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;TypeScript mainly sees:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"A function returning boolean"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;not:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"This removes undefined and null values from the array"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That relationship gets lost.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why &lt;code&gt;!!value&lt;/code&gt; Feels Different
&lt;/h1&gt;

&lt;p&gt;This is similar to another TypeScript behavior:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;isValid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;!!&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;usually narrows correctly, while:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;isValid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;often does not.&lt;/p&gt;

&lt;p&gt;Even though both behave similarly at runtime.&lt;/p&gt;

&lt;p&gt;The reason is that TypeScript recognizes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="o"&gt;!!&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;as a direct truthiness check pattern.&lt;/p&gt;

&lt;p&gt;But:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nc"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;looks like a normal function call from the compiler’s perspective.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Correct TypeScript-Friendly Fix
&lt;/h1&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;values&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;use an explicit type predicate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;values&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="nb"&gt;NonNullable&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now TypeScript understands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;“If this function returns true,
this value is not null or undefined.”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So this works safely:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;values&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;without narrowing issues.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Problem
&lt;/h1&gt;

&lt;p&gt;This fix is technically correct.&lt;/p&gt;

&lt;p&gt;But after seeing this pattern repeatedly across projects, I realized something:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;this is mostly mechanical work
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A developer already knows what they meant.&lt;/p&gt;

&lt;p&gt;The compiler just needs help understanding it.&lt;/p&gt;

&lt;p&gt;And that made me wonder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Could this be fixed automatically?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Building an AST Fixer for It
&lt;/h1&gt;

&lt;p&gt;I’ve been building a small TypeScript CLI tool called &lt;code&gt;fixmyfile&lt;/code&gt; that automatically repairs repetitive TypeScript friction using compiler diagnostics and AST transformations.&lt;/p&gt;

&lt;p&gt;One of the fixes now detects:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and transforms it into:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="nb"&gt;NonNullable&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;automatically.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Interesting Part
&lt;/h1&gt;

&lt;p&gt;The transformation itself was not the hardest part.&lt;/p&gt;

&lt;p&gt;The harder part was making the fix:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;predictable&lt;/li&gt;
&lt;li&gt;safe&lt;/li&gt;
&lt;li&gt;repeatable&lt;/li&gt;
&lt;li&gt;compiler-aware&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;because TypeScript diagnostics and AST nodes do not always align exactly the way you initially expect.&lt;/p&gt;

&lt;p&gt;That was the moment I started realizing how much developer tooling is really about:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;understanding compiler behavior deeply
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;instead of simply replacing strings.&lt;/p&gt;




&lt;h1&gt;
  
  
  One Thing I’ve Learned Building This
&lt;/h1&gt;

&lt;p&gt;A surprising amount of TypeScript frustration comes from:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;small repetitive mechanical fixes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;not huge architectural problems.&lt;/p&gt;

&lt;p&gt;Things like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;optional chaining insertion&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.filter(Boolean)&lt;/code&gt; narrowing&lt;/li&gt;
&lt;li&gt;missing arguments&lt;/li&gt;
&lt;li&gt;repetitive null checks&lt;/li&gt;
&lt;li&gt;strict-mode cleanup&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;individually feel tiny.&lt;/p&gt;

&lt;p&gt;But repeated hundreds of times, they slowly create workflow friction.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;I don’t think TypeScript is wrong here.&lt;/p&gt;

&lt;p&gt;The compiler is being conservative intentionally.&lt;/p&gt;

&lt;p&gt;But I do think there’s a growing opportunity for tooling that helps bridge the gap between:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;what developers obviously mean
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;what the compiler can safely infer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s the direction I’ve been exploring recently with AST-based fixes and compiler-driven transformations.&lt;/p&gt;

&lt;p&gt;And honestly, it has been one of the most interesting parts of working with TypeScript so far.&lt;/p&gt;




&lt;p&gt;If you’ve run into similar TypeScript friction patterns repeatedly, I’d genuinely love to hear which ones annoy you the most.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Extending my TypeScript auto-fix CLI to handle .filter(Boolean) narrowing issues</title>
      <dc:creator>i-am-killvish</dc:creator>
      <pubDate>Mon, 04 May 2026 16:29:23 +0000</pubDate>
      <link>https://dev.to/iamkillvish/extending-my-typescript-auto-fix-cli-to-handle-filterboolean-narrowing-issues-21cd</link>
      <guid>https://dev.to/iamkillvish/extending-my-typescript-auto-fix-cli-to-handle-filterboolean-narrowing-issues-21cd</guid>
      <description>&lt;p&gt;A few days ago I shared a small CLI experiment called &lt;code&gt;fixmyfile&lt;/code&gt; that automatically fixes repetitive TypeScript errors using compiler diagnostics and AST transformations.&lt;/p&gt;

&lt;p&gt;While testing it more, I kept running into another frustrating TypeScript pattern:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;u&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even after filtering values, TypeScript can still complain that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'u' is possibly undefined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Logically the values are already filtered, but TypeScript narrowing does not always behave the way developers expect.&lt;/p&gt;

&lt;p&gt;So I started experimenting with AST-based transformations for these cases too.&lt;/p&gt;

&lt;p&gt;Now the CLI automatically converts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;into:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="nb"&gt;NonNullable&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;which preserves narrowing correctly and removes the repeated &lt;code&gt;"possibly undefined"&lt;/code&gt; friction afterward.&lt;/p&gt;

&lt;p&gt;What’s been interesting while building this project is realizing how many TypeScript frustrations are not necessarily difficult problems, but repetitive workflow interruptions developers hit every day.&lt;/p&gt;

&lt;p&gt;Still very experimental, but AST transformations are turning out to be much more powerful than simple text replacements.&lt;/p&gt;

&lt;p&gt;Current fixes supported:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Missing function arguments (&lt;code&gt;TS2554&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Basic type mismatch fixes (&lt;code&gt;TS2322&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Undefined references (&lt;code&gt;TS2304&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.filter(Boolean)&lt;/code&gt; narrowing transformations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;GitHub:&lt;br&gt;
&lt;a href="https://github.com/i-am-killvish/fixmyfile" rel="noopener noreferrer"&gt;https://github.com/i-am-killvish/fixmyfile&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Would love feedback on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;other repetitive TS friction points&lt;/li&gt;
&lt;li&gt;weird narrowing cases&lt;/li&gt;
&lt;li&gt;compiler issues developers repeatedly fight with&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>typescript</category>
      <category>opensource</category>
      <category>javascript</category>
      <category>productivity</category>
    </item>
    <item>
      <title>I built a CLI that fixes TypeScript errors automatically</title>
      <dc:creator>i-am-killvish</dc:creator>
      <pubDate>Sat, 25 Apr 2026 01:20:24 +0000</pubDate>
      <link>https://dev.to/iamkillvish/i-built-a-cli-that-fixes-typescript-errors-automatically-8e3</link>
      <guid>https://dev.to/iamkillvish/i-built-a-cli-that-fixes-typescript-errors-automatically-8e3</guid>
      <description>&lt;p&gt;Fixing TypeScript errors like:&lt;/p&gt;

&lt;p&gt;“Expected 1 arguments, but got 0 (TS2554)”&lt;/p&gt;

&lt;p&gt;gets repetitive really fast.&lt;/p&gt;

&lt;p&gt;So I built a small CLI tool called fixmyfile that automatically fixes some common TypeScript errors using the compiler API and AST transformations.&lt;/p&gt;

&lt;h2&gt;
  
  
  ⚡ Demo
&lt;/h2&gt;

&lt;p&gt;Fixing a TypeScript error automatically:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3vlll5uad82m62pq4tmt.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3vlll5uad82m62pq4tmt.gif" alt=" " width="720" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🧠 What it does
&lt;/h2&gt;

&lt;p&gt;The tool:&lt;/p&gt;

&lt;p&gt;scans a .ts file&lt;br&gt;
detects TypeScript compiler errors&lt;br&gt;
applies automatic fixes&lt;br&gt;
repeats until no more changes are possible&lt;/p&gt;

&lt;h2&gt;
  
  
  ⚡ Example
&lt;/h2&gt;

&lt;p&gt;❌ Before&lt;br&gt;
function greet(name: string) {&lt;br&gt;
  console.log(name);&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;greet(); // missing args&lt;br&gt;
✅ After&lt;br&gt;
greet("text");&lt;/p&gt;

&lt;h2&gt;
  
  
  🖥 Try it
&lt;/h2&gt;

&lt;p&gt;You can run it directly using:&lt;/p&gt;

&lt;p&gt;npx fixmyfile yourfile.ts&lt;/p&gt;

&lt;h2&gt;
  
  
  🧩 Currently supports
&lt;/h2&gt;

&lt;p&gt;Missing function arguments (TS2554)&lt;br&gt;
Basic type mismatch fixes (TS2322)&lt;br&gt;
Undefined references (TS2304)&lt;/p&gt;

&lt;h2&gt;
  
  
  ⚠️ Note
&lt;/h2&gt;

&lt;p&gt;This is still experimental and focuses on common, repetitive fixes.&lt;br&gt;
Always review the output before committing changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  💬 Feedback
&lt;/h2&gt;

&lt;p&gt;Would love to know:&lt;/p&gt;

&lt;p&gt;Did it work on your code?&lt;br&gt;
What errors should it support next?&lt;br&gt;
Where did it break?&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://github.com/i-am-killvish/fixmyfile" rel="noopener noreferrer"&gt;https://github.com/i-am-killvish/fixmyfile&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 Why I built this
&lt;/h2&gt;

&lt;p&gt;I kept running into the same TypeScript errors du&lt;a href="![%20](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r0oxhmpvz70yltsh90uz.gif)"&gt;&lt;/a&gt;ring development and realized many of them are predictable enough to automate.&lt;/p&gt;

&lt;p&gt;This is an early attempt at making that process faster.&lt;/p&gt;

&lt;p&gt;If this sounds useful, give it a try and let me know what you think 🙂&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>productivity</category>
      <category>javascript</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
