<?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: Brian Opedal</title>
    <description>The latest articles on DEV Community by Brian Opedal (@brianopedal).</description>
    <link>https://dev.to/brianopedal</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%2F1264479%2Fe46a1593-f817-4531-b581-11c37712e32a.jpg</url>
      <title>DEV Community: Brian Opedal</title>
      <link>https://dev.to/brianopedal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/brianopedal"/>
    <language>en</language>
    <item>
      <title>#noImplicitOverride in tsconfig.json</title>
      <dc:creator>Brian Opedal</dc:creator>
      <pubDate>Wed, 24 Jan 2024 03:26:49 +0000</pubDate>
      <link>https://dev.to/brianopedal/noimplicitoverride-in-tsconfigjson-6na</link>
      <guid>https://dev.to/brianopedal/noimplicitoverride-in-tsconfigjson-6na</guid>
      <description>&lt;h2&gt;
  
  
  Set &lt;code&gt;noImplicitOverride: true&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;It lets Typescript do more of what typescript is meant to do. &lt;br&gt;
And its usually a quick and easy increase of type-safety in your codebase.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.typescriptlang.org/tsconfig#noImplicitOverride"&gt;#noImplicitOverride&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here are 3 reasons why you &lt;strong&gt;should&lt;/strong&gt; set tsconfig.json #noImplicitOverride&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Prevents Overrides that don't actually override:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It prevents your developers from mistakenly thinking they are overriding something when they are not, preventing errors like spelling mistakes or attempting to override a removed/updated method/variable on the base class.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Ensures Up-to-Date Sub-classes:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Lets Typescript give an error if a subclass becomes outdated due to changes in the base class, such as the removal or modification of a method. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Requires Explicit Method Signature:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The &lt;code&gt;override&lt;/code&gt; keyword shows clearly what the intention&lt;br&gt;
of the method is. If it's not there you would have to go to the base class (and potentially to its base and so forth) to see if the method is overridden or not.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to do it?
&lt;/h2&gt;

&lt;p&gt;a. In your &lt;code&gt;tsconfig.json&lt;/code&gt; just add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"compilerOptions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"noImplicitOverride"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;b. run a typecheck and fix all classes by adding &lt;code&gt;override&lt;/code&gt; to the methods and class variables.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>webdev</category>
      <category>dx</category>
      <category>tsconfig</category>
    </item>
  </channel>
</rss>
