DEV Community

TusharShahi
TusharShahi

Posted on

4

TypeScript Tip #3: Folder-wise config

The file tsconfig.json indicates that the project is using typescript. It specifies the different options required to compile the project.

There are situations when you are working on a huge project and migrating it from JavaScript to TypeScript. While new code is well-typed the older code is in a state where type-checking can not be as strict.

The need arises for different levels of type strictness in different sub-folders of the same project. This can be achieved using multiple config files.

Example: You do not allow the type any in your new subfolder. But the rest of your project being much legacy, still uses any here and there.

You can have "noImplicitAny": false in your main config file.

Inside the new subfolder, you can have another tsconfig.json file, which extends the main tsconfig.

{
  "extends": "../../../tsconfig.json",
  "compilerOptions": {
    "noImplicitAny": true
  },
  "include": ["*"]
}
Enter fullscreen mode Exit fullscreen mode

This is a game changer for huge projects and allows for agile development.

Postgres on Neon - Get the Free Plan

No credit card required. The database you love, on a serverless platform designed to help you build faster.

Get Postgres on Neon

Top comments (0)

Cloudinary image

Optimize, customize, deliver, manage and analyze your images.

Remove background in all your web images at the same time, use outpainting to expand images with matching content, remove objects via open-set object detection and fill, recolor, crop, resize... Discover these and hundreds more ways to manage your web images and videos on a scale.

Learn more

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️