Add option to include files in type checking, but not compiling #54410
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
Suggestion
π Search Terms
rootDir
exclude
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
I would love to have an option to include files for type checking, but not compiling.
One solution would be to add an option (
checkOutsideRootDir
?) to support type checking files outside therootDir
. An alternative way could be to provide separate glob patterns for type checking and compiling.π Motivating Example
Letβs say you are testing you project with Vitest. You probably have a file structure that looks something like this:
Previously you needed two TypeScript configuration files, one for type checking everything, and one for compiling your source code. With this new option enabled, TypeScript will type check all TypeScript files, but it will only compile the files from the
rootDir
directory.π» Use Cases
Currently I feel like there is no proper way to configure TypeScript for both type checking and compiling. Some special configuration is needed to compile source code, and type check tests / config files, but exclude those from the build.
Often repos end up with
tsconfig.json
and something along the way oftsconfig.build.json
,tsconfig-prod.json
,dev.tsconfig.json
, or something along those lines. Itβs not consistent across the ecosystem. This file then uses a mix ofextends
/include
/exclude
to create complex configurations. Alternatively people just exclude certain files, not being aware they are being excluded from type checking as well. Or they use an alternative tool for building.Regardless of what people come up with, it often leads to awkward configurations.
The text was updated successfully, but these errors were encountered: