PRO 30% Free • PayPal ($15) & Razorpay (₹899)
30%

The tsconfig.json File

Top Course Staff · 2 min read · Web development · PRO · 30% Free Preview Available

The tsconfig.json File

TypeScript features are extremely useful: for one, it allows us to add types to regularJavaScriptcode. It also checks for syntax errors even before run time. It even provides tooltips that show you why some code might throw an error. There are so many great features that come by default. Even with all these great features, TypeScript recognizes the need for flexibility.

Sometimes, you don’t want all thedefault rulesthat TypeScript is trying to enforce — and that’s fine. That’s one reason why providing atsconfig.jsonfile is useful. Additionally, you get perks like telling the TypeScript compiler what files to run on and more! So, let’s explore what this file looks like and how it helps.

Sample tsconfig.json and Breakdown

Thetsconfig.jsonfile is always placed in the root of your project and you can customize what rules you want the TypeScript compiler to enforce. Here’s thetsconfig.jsonfile we provide in every single exercise and project in our Learn TypeScript course:

{  "compilerOptions": {    "target": "es2017",    "module": "commonjs",    "strictNullChecks": true  },  "include": ["**/*.ts"]}
Copy to clipboard
{  "compilerOptions": {    "target": "es2017",    "module": "commonjs",    "strictNullChecks": true  },  "include": ["**/*.ts"]}

In theJSON, there are several properties:

  • "compilerOptions", which is a nested object that contains the rules for the TypeScript compiler to enforce."target", the value"es2017"means the project will be using the 2017 version of EcmaScript standards for JavaScript."module", this project will be using"commonjs"syntaxto import and export modules."strictNullChecks", variables can only havenullorundefinedvalues if they are explicitly assigned those values.
  • "include"that determines what files the compiler applies the rules to. In this case["**/*.ts"]means the compiler should check every single file that has a.tsextension.

We chose these rules because we wanted to give you an idea of what rules to enforce and still allow your creativity to shine. For your own projects, you can set these rules to your own preferences! Thetsconfig.jsonfile is great for both individual work and team projects because it allows everyone to be on the same page about how to write their code.

Usage

Another neat addition is that by including atsconfig.jsonfile, you can now use the commandtscwithout any arguments in your terminal! The compiler will automatically recognize from yourtsconfig.jsonfile, what specific files to run on. You can still provide specific files liketsc fileName.tsif that’s the only file you want the compiler to check.

Wrap up

Check out TypeScript’scompiler option documentationfor even more information.

Happy Coding! And remember, when in doubt,typeit out!

'The Codecademy Team, composed of experienced educators and tech experts, is dedicated to making tech skills accessible to all. We empower learners worldwide with expert-reviewed content that develops and enhances the technical skills needed to advance and succeed in their careers.'

30% Free Preview Reached · Unlock Remaining 70%

Complete Payment to Unlock Full Guide & Source Code

You are viewing the 30% preview. Join TopCourseAI Pro to unlock the remaining 70% of this article, unblur all code snippets, and gain full access to all 412 technical projects and guides.

✓ Full Access to All 160+ Projects
✓ Instant Blur Removal Everywhere
✓ Production Source Code & Blueprints
✓ All Future Deep Dives Included
Instant Unhindered Activation ·
End of Preview · Unlock Complete Blueprint & Source Code

Ready to access the complete step-by-step tutorial?

Gain full unhindered access to all 412 technical projects and guides, unblur all source code snippets, and download runnable scripts.

Step-by-Step Project Library

Ready to start building your next project?

Enjoyed this guide? Continue exploring our library of 412+ step-by-step guides, starter files, and practical projects across Web Development, Mobile Apps, AI, and Design.