Redundant configurations in tsconfig.json?
vincentpun opened this issue · 2 comments
Hi, I was using this project to build a worker on Cloudflare. I was trying to add @types/mocha
but noticed that I had to add every global declaration I installed to compilerOptions.types
in TSConfig. After some investigation, I believe there are possible redundant configurations in the file:
-
The
exclude
property is only necessary if you want to exclude files or directories that are included using theinclude
property (See TypeScript TSConfig Reference). The original specified directories in theexclude
property, namelynode_modules
anddist
, are not covered ininclude
, so it's redundant. -
Since
./node_modules/@cloudflare/workers-types/index.d.ts
is included in theinclude
property, but then excluded as the wholenode_modules
directory is excluded (as specified in theexclude
property), I suspect that the typing information did not work and hence a fix was attempted by adding@cloudflare/workers-types
tocompilerOptions.types
. -
Unfortunately, adding
compilerOptions.types
will cause TypeScript to only use global declarations in the specified folders (See TypeScript TSConfig Reference). As a result, all global declarations elsewhere (notably,./node_modules/@types
) are now completely ignored, so I had to manually addmocha
tocompilerOptions.types
.
As this is a batteries-included template, I should expect most things to work relatively similar to the most common use-case, that is, installing @types
packages should work immediately without tinkering with the compilerOptions.types
property.
I have a fix in my own fork (tsconfig-fixes branch) and ready for a PR, but I just wanted to open this issue to make sure my line of thought is correct.
Thanks!
LGTM. Could make sense to have this merged @signalnerve :)
Looks like this is still relevant, any reason not to open and merge the PR?