- Added typesIncludesWildcard() function in moduleNameResolver.ts
- Updated all wildcard checks to use the helper function:
- checker.ts: getCannotFindNameDiagnosticForName
- programDiagnostics.ts: FileIncludeKind.AutomaticTypeDirectiveFile
- watch.ts: fileIncludeReasonToRelatedInformation
- resolutionCache.ts: updateTypeRootsWatch
- jsTyping.ts: discoverTypings
- Added imports in all consuming files
This centralizes the wildcard checking logic and makes the code more maintainable.
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
- checker.ts: Check for wildcard before choosing error message
- programDiagnostics.ts: Check for wildcard before returning early
- watch.ts: Check for wildcard to choose correct message
- jsTyping.ts: Use optional chaining for wildcard check
- tscWatch tests: Use wildcard for tests that dynamically install types
These functions should only show "add to types" messages when wildcard is NOT present.
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
- Updated getCannotFindNameDiagnosticForName to always suggest adding to types field
- Fixed FileIncludeKind.AutomaticTypeDirectiveFile messages to always show "specified in compilerOptions"
- Updated updateTypeRootsWatch to check for wildcard instead of just checking if types exists
- Updated discoverTypings to discover when types is undefined or includes wildcard
These changes ensure the new types default behavior is properly reflected in error messages and file watching.
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Added explicit types arrays to tests that had NEW errors after the default change:
- tsc/incremental: react-jsx tests now have types: ["react"]
- tsbuild/moduleResolution: type-reference-resolution test now has types: ["sometype"]
- tscWatch/resolutionCache: tests now have types: ["node"]
- tsserver tests: added types for node, lib1, lib2, typings
- compiler tests: jsDeclarationsTypeReferences and typeReferenceDirectives tests now have explicit @types directives
All tests now pass with only expected errors (no unintentional changes).
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
- Early return when hasWildcard is false
- Remove explanatory comments as code is self-documenting
- Addresses code review feedback
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
- Enhanced wildcard logic to support mixing "*" with explicit types
- Added test for wildcard combined with explicit types
- This supports gradual migration pattern: types: ["*", "node", "jest"]
- All 99,255 tests passing
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Updated tests to explicitly specify types they depend on:
- Added "types": ["node"] to tests requiring @types/node
- Added "types": ["react"] to tests requiring @types/react
- Added "types": ["classnames"] to UMD module tests
- Added "types": ["*"] to external project test to maintain old behavior
- Fixed autoImportPackageJsonFilterExistingImport3 test structure
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
- Modified getAutomaticTypeDirectiveNames to return empty array when types is undefined
- Added support for "*" wildcard value to opt into old "include all" behavior
- Created comprehensive test cases for new functionality
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>