In 6.0, we plan to disable automatic inclusion of every file in `node_modules/@types`. In 6.0, these packages will need to be brought in via imports, or explicitly listed in your `tsconfig.json`'s `types`. ```json5 { "compilerOptions": { // ... // ℹ️ Packages with globals go here now! "types": [ "node", "mocha", "jest", "jasmine", "...", ], } } ``` To opt into the old auto-inclusion behavior, we will need an explicit opt-in. We are thinking that this could just be the presence of an entry like `"*"` in the types array. ```json5 { "compilerOptions": { "types": ["*"], } } ``` This can make migration easier, as developers can easily keep/remove the `"*"`, and add entries to the list as they are encountered ```json5 { "compilerOptions": { "types": [ "*", // Temporarily necessary for 6.0/7.0 upgrade. "other", "globals", "go", "here" ], } } ``` > [!IMPORTANT] > Read the above carefully - this does not mean we will stop reading from `node_modules/@types`, just that the files won't be brought in unless > * imported > * explicitly listed in your `tsconfig.json`'s `types` array. > * brought in with `/// <reference types="..." />` (please try to avoid doing this) > > Typically this will only affect users relying on global values and module names, like those brought in from `@types/node` (e.g. the `"fs"` module is globally defined), or a testing framework. ___ More rationale from #54500: > Currently, the `types` value defaults to "enumerate everything in `node_modules/@types`". This is potentially *very* expensive as a normal repo setup these days might transitively pull in hundreds of `@types` packages. Modern projects almost always need only `@types/node`, `@types/jest`, or a handful of other common global-affecting packages. > > In 6.0, the default `types` value will be `[]`. > *This will affect many projects*; you will likely need to add `"types": ["node"]` or a few others. > > This will prevent projects from unintentionally pulling in hundreds or even thousands of unneeded declaration files at build time. Many projects we've looked at have improved their build time anywhere from 20-50% just by setting `types` appropriately.