<?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: Anatoly Nevzorov</title>
    <description>The latest articles on DEV Community by Anatoly Nevzorov (@zorrr).</description>
    <link>https://dev.to/zorrr</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%2F3427542%2F751e3013-1218-4bf5-b6ae-80ab777a8f81.png</url>
      <title>DEV Community: Anatoly Nevzorov</title>
      <link>https://dev.to/zorrr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zorrr"/>
    <language>en</language>
    <item>
      <title>Mastering tsconfig.json in TypeScript</title>
      <dc:creator>Anatoly Nevzorov</dc:creator>
      <pubDate>Mon, 11 Aug 2025 15:39:54 +0000</pubDate>
      <link>https://dev.to/zorrr/mastering-tsconfigjson-in-typescript-5bk</link>
      <guid>https://dev.to/zorrr/mastering-tsconfigjson-in-typescript-5bk</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;What is tsconfig.json?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;tsconfig.json&lt;/code&gt; file is the &lt;strong&gt;"recipe book"&lt;/strong&gt; of the TypeScript compiler. It tells TypeScript how to "cook" your code: which ingredients (options) to use, how long to simmer (compile), and where to serve the final JavaScript output. Without it, a TypeScript project is like a chef without a recipe—chaos and confusion reign.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Key Sections of tsconfig.json&lt;/strong&gt;
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;1. &lt;code&gt;compilerOptions&lt;/code&gt; — The "Recipe Book"&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;This section holds &lt;strong&gt;all critical compilation settings&lt;/strong&gt;. Examples include:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;target&lt;/code&gt;&lt;/strong&gt;: Specifies the JavaScript version to transpile to (e.g., &lt;code&gt;ES5&lt;/code&gt;, &lt;code&gt;ES2020&lt;/code&gt;).&lt;br&gt;&lt;br&gt;
&lt;em&gt;Metaphor&lt;/em&gt;: Like choosing the difficulty level of a recipe—from basic (ES5) to modern (ES2020).  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;module&lt;/code&gt;&lt;/strong&gt;: Defines the module system (CommonJS, ES6).&lt;br&gt;&lt;br&gt;
&lt;em&gt;Example&lt;/em&gt;: &lt;code&gt;module: "ESNext"&lt;/code&gt; uses the latest experimental modules, as if you’re on the tech frontier.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;strict&lt;/code&gt;&lt;/strong&gt;: Enables "strict mode," enforcing type safety and optional fields.&lt;br&gt;&lt;br&gt;
&lt;em&gt;Association&lt;/em&gt;: Imagine your code attending school with a meticulous teacher.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;outDir&lt;/code&gt; and &lt;code&gt;rootDir&lt;/code&gt;&lt;/strong&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;rootDir&lt;/code&gt;: The root of your raw TypeScript code.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;outDir&lt;/code&gt;: The folder for the compiled JS output.
&lt;em&gt;Metaphor&lt;/em&gt;: Think of &lt;code&gt;rootDir&lt;/code&gt; as the kitchen door and &lt;code&gt;outDir&lt;/code&gt; as the buffet where dishes are served.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;2. &lt;code&gt;include&lt;/code&gt;, &lt;code&gt;exclude&lt;/code&gt;, &lt;code&gt;files&lt;/code&gt; — The "Shopping List"&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;include&lt;/code&gt;&lt;/strong&gt;: Lists directories/files to compile.&lt;br&gt;&lt;br&gt;
&lt;em&gt;Example&lt;/em&gt;: &lt;code&gt;include: ["src/**/*"]&lt;/code&gt; compiles everything in the &lt;code&gt;src&lt;/code&gt; folder.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;exclude&lt;/code&gt;&lt;/strong&gt;: Excludes files (e.g., &lt;code&gt;node_modules&lt;/code&gt;).&lt;br&gt;&lt;br&gt;
&lt;em&gt;Association&lt;/em&gt;: A list of ingredients forbidden in the recipe.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;files&lt;/code&gt;&lt;/strong&gt;: Explicitly lists specific files.&lt;br&gt;&lt;br&gt;
&lt;em&gt;When to use?&lt;/em&gt; For small projects or when precise control is needed.  &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Advanced Settings&lt;/strong&gt;
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;1. Paths and Aliases (&lt;code&gt;baseUrl&lt;/code&gt;, &lt;code&gt;paths&lt;/code&gt;)&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;baseUrl&lt;/code&gt;&lt;/strong&gt;: Sets the base directory for relative imports.&lt;br&gt;&lt;br&gt;
&lt;em&gt;Example&lt;/em&gt;: Set &lt;code&gt;baseUrl: "src"&lt;/code&gt; to import like &lt;code&gt;import MyComponent from 'components/MyComponent'&lt;/code&gt;.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;paths&lt;/code&gt;&lt;/strong&gt;: Creates aliases to simplify imports.&lt;br&gt;&lt;br&gt;
&lt;em&gt;Example&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nl"&gt;"paths"&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="nl"&gt;"@models/*"&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="s2"&gt;"src/models/*"&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;&lt;em&gt;Metaphor&lt;/em&gt;: Like creating shortcuts in a file explorer—faster and cleaner.  &lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;2. Compilation Optimization&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;watch&lt;/code&gt;&lt;/strong&gt;: Auto-recompiles on file changes.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;incremental&lt;/code&gt;&lt;/strong&gt;: Saves intermediate results to speed up future builds.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;build&lt;/code&gt;&lt;/strong&gt;: Multi-project builds (ideal for libraries).
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Practical Examples&lt;/strong&gt;
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;1. Simple Project&lt;/strong&gt;
&lt;/h4&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="nl"&gt;"target"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ES2020"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"module"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ESNext"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"strict"&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="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"outDir"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./dist"&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="nl"&gt;"include"&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="s2"&gt;"src/**/*"&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;h4&gt;
  
  
  &lt;strong&gt;2. Library with Aliases&lt;/strong&gt;
&lt;/h4&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="nl"&gt;"baseUrl"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"paths"&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="nl"&gt;"@utils/*"&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="s2"&gt;"src/utils/*"&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="nl"&gt;"declaration"&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="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Generates&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;`.d.ts`&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;files&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;publishing&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;h3&gt;
  
  
  &lt;strong&gt;Key Takeaways&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;tsconfig.json&lt;/code&gt; is the heart of a TypeScript project&lt;/strong&gt;. Proper setup saves time and prevents errors.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Strict mode (&lt;code&gt;strict&lt;/code&gt;)&lt;/strong&gt; is your friend if you want to avoid "silent" bugs.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Aliases (&lt;code&gt;paths&lt;/code&gt;)&lt;/strong&gt; make imports cleaner and simplify refactoring.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Optimization flags&lt;/strong&gt; (&lt;code&gt;watch&lt;/code&gt;, &lt;code&gt;incremental&lt;/code&gt;) are vital for large projects.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Understanding &lt;code&gt;outDir&lt;/code&gt; and &lt;code&gt;rootDir&lt;/code&gt;&lt;/strong&gt; avoids path confusion.
&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;How to Get Started?&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Create a &lt;code&gt;tsconfig.json&lt;/code&gt; using &lt;code&gt;tsc --init&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;Start with basics: &lt;code&gt;target&lt;/code&gt;, &lt;code&gt;module&lt;/code&gt;, and &lt;code&gt;strict&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;include&lt;/code&gt; and &lt;code&gt;exclude&lt;/code&gt; to control compilation.
&lt;/li&gt;
&lt;li&gt;Experiment with aliases and optimizations as your project grows.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;code&gt;tsconfig.json&lt;/code&gt; isn’t just a file—it’s a &lt;strong&gt;project management strategy&lt;/strong&gt;. When configured correctly, it turns chaos into structure and bugs into opportunities for improvement.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>frontend</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
