Set default types array to []; support "*" wildcard - #63054
Conversation
|
Looks like you're introducing a change to the public API surface area. If this includes breaking changes, please document them on our wiki's API Breaking Changes page. Also, please make sure Daniel Rosenwasser (@DanielRosenwasser) and Ryan Cavanaugh (@RyanCavanaugh) are aware of the changes, just as a heads up. |
There was a problem hiding this comment.
Pull request overview
This pull request implements a breaking change to TypeScript's types compiler option, setting its default to an empty array ([]) instead of automatically including all packages from node_modules/@types. A wildcard ("*") is introduced to allow users to opt into the old "include all" behavior for backward compatibility.
Changes:
- Modified
getAutomaticTypeDirectiveNamesto return[]by default whentypesis undefined and support"*"wildcard expansion - Added
usesWildcardTypeshelper function to centralize wildcard detection logic - Updated error messages to suggest adding types to the
typesfield in tsconfig when wildcard is not present - Updated 29+ tests to explicitly use
"types": ["*"]where automatic type discovery was relied upon
Reviewed changes
Copilot reviewed 171 out of 265 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/compiler/moduleNameResolver.ts | Core logic: changes getAutomaticTypeDirectiveNames to default to [] and support wildcard expansion |
| src/compiler/utilities.ts | Adds usesWildcardTypes helper to check if types array includes "*" |
| src/compiler/checker.ts | Updates error messages to conditionally suggest adding types to tsconfig |
| src/compiler/programDiagnostics.ts | Updates file include diagnostics to handle wildcard |
| src/compiler/watch.ts | Updates watch mode file include reasons for wildcard |
| src/jsTyping/jsTyping.ts | Updates type discovery to use wildcard check |
| tests/cases/fourslash/server/* | Adds "types": ["*"] to tests requiring auto-discovery |
| tests/cases/conformance/* | Adds // @types: * directive to compiler tests |
| tests/baselines/reference/* | Updates baselines for new error messages and behavior |
Jake Bailey (jakebailey)
left a comment
There was a problem hiding this comment.
Seems like some tests are still left.
I do also wonder if we need to be forcing this on for inferred projects in tsserver...
|
TypeScript Bot (@typescript-bot) test top800 |
|
Jake Bailey (@jakebailey) Here are the results of running the top 800 repos with tsc comparing Something interesting changed - please have a look. Details
|
|
Jake Bailey (@jakebailey) Here are some more interesting changes from running the top 800 repos suite Details
|
|
Jake Bailey (@jakebailey) Here are some more interesting changes from running the top 800 repos suite Details
|
|
Jake Bailey (@jakebailey) Here are some more interesting changes from running the top 800 repos suite Details
|
Pull request was closed
Blame: microsoft/TypeScript#63054 TypeScript are moving to explicit types instead of catch-all by default. This means that projects need to have a types entry if they want to rely on additional types. This was surfaced by our canary job on February 5: https://github.com/remeda/remeda/actions/runs/21703126297/job/62587774821
One of the changes in Typescript v6 is types now defaults to [] in order to avoid pulling in unecessary dependencies. https://devblogs.microsoft.com/typescript/announcing-typescript-6-0/ Introduced in: microsoft/TypeScript#63054 Proposal here: microsoft/TypeScript#62195
Redo of #63031 with slightly more manageable commit history
Fixes #62195