Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7c95cfb
Add utility function; update sites that depend on old wildcard behavior
RyanCavanaugh Jan 27, 2026
b18e524
Make the code change in core utils
RyanCavanaugh Jan 27, 2026
03a711e
Add baselines that just change error message
RyanCavanaugh Jan 27, 2026
0c104b8
Trace-only changes, hopefully
RyanCavanaugh Jan 28, 2026
9ec13ae
Update testcases
RyanCavanaugh Jan 28, 2026
c1d487f
More traces
RyanCavanaugh Jan 28, 2026
d0db3cc
Format
RyanCavanaugh Jan 28, 2026
5186331
One more test
RyanCavanaugh Jan 28, 2026
499cd4c
Update .d.ts
RyanCavanaugh Jan 28, 2026
2312bd9
Update typingsInstaller tests
RyanCavanaugh Jan 28, 2026
787f9b6
Fix misc unit tests
RyanCavanaugh Jan 29, 2026
868fb7c
Add types: * to auto-import unit test
RyanCavanaugh Jan 29, 2026
423e1c4
Use wildcard types for inferred JS project unless otherwise directed
RyanCavanaugh Jan 29, 2026
00c6b56
Correctly handle lack of needed wildcard watch on types
RyanCavanaugh Jan 29, 2026
7659973
Corrected test corrections
RyanCavanaugh Jan 29, 2026
1795860
Fix test with incorrect tsconfig
RyanCavanaugh Jan 30, 2026
9f5dbbd
Correctly attribute wildcard types
RyanCavanaugh Jan 30, 2026
e5d646b
Recommend installing types/node for missing modules
RyanCavanaugh Jan 30, 2026
7382bbb
lint
RyanCavanaugh Jan 30, 2026
27b74d6
Offer installing @types/node when can't resolve nodejs modules
RyanCavanaugh Jan 30, 2026
49086b2
Update src/compiler/programDiagnostics.ts
RyanCavanaugh Jan 30, 2026
8a9515d
Follow-up to Sheetal's edit
RyanCavanaugh Jan 30, 2026
ec8e039
Add timeout run so we can see zero errors in this test
RyanCavanaugh Jan 30, 2026
dd8df7a
Same for this test
RyanCavanaugh Jan 30, 2026
25b88ea
Merge remote-tracking branch 'upstream/main' into fix62195_2
RyanCavanaugh Jan 30, 2026
d398d5b
Merge conflicted fourslash tests
RyanCavanaugh Jan 30, 2026
c374421
typo
RyanCavanaugh Jan 30, 2026
5dc64a2
Format
RyanCavanaugh Jan 30, 2026
46c6b0c
merge w/ main
RyanCavanaugh Feb 4, 2026
3f2b383
Add * to unit tests that need it
RyanCavanaugh Feb 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,7 @@ import {
UnionType,
UnionTypeNode,
UniqueESSymbolType,
usesWildcardTypes,
usingSingleLineStringWriter,
VariableDeclaration,
VariableDeclarationList,
Expand Down Expand Up @@ -27628,27 +27629,27 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
case "console":
return Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom;
case "$":
return compilerOptions.types
? Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig
: Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery;
return usesWildcardTypes(compilerOptions)
? Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery
: Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig;
case "describe":
case "suite":
case "it":
case "test":
return compilerOptions.types
? Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig
: Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha;
return usesWildcardTypes(compilerOptions)
? Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha
: Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig;
case "process":
case "require":
case "Buffer":
case "module":
return compilerOptions.types
? Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig
: Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode;
return usesWildcardTypes(compilerOptions)
? Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode
: Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig;
case "Bun":
return compilerOptions.types
? Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun_and_then_add_bun_to_the_types_field_in_your_tsconfig
: Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun;
return usesWildcardTypes(compilerOptions)
? Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun
: Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun_and_then_add_bun_to_the_types_field_in_your_tsconfig;
case "Map":
case "Set":
case "Promise":
Expand Down
19 changes: 12 additions & 7 deletions src/compiler/moduleNameResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ import {
emptyArray,
endsWith,
ensureTrailingDirectorySeparator,
equateValues,
every,
Extension,
extensionIsTS,
fileExtensionIs,
fileExtensionIsOneOf,
filter,
firstDefined,
flatten,
forEach,
forEachAncestorDirectory,
formatMessage,
Expand Down Expand Up @@ -105,6 +107,7 @@ import {
tryExtractTSExtension,
tryGetExtensionFromPath,
tryParsePatterns,
usesWildcardTypes,
Version,
version,
versionMajorMinor,
Expand Down Expand Up @@ -803,18 +806,17 @@ export function resolvePackageNameToPackageJson(
* Given a set of options, returns the set of type directive names
* that should be included for this program automatically.
* This list could either come from the config file,
* or from enumerating the types root + initial secondary types lookup location.
* and/or from enumerating the types root + initial secondary types lookup location given "*" compat wildcard.
* More type directives might appear in the program later as a result of loading actual source files;
* this list is only the set of defaults that are implicitly included.
*/
export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[] {
// Use explicit type list from tsconfig.json
if (options.types) {
return options.types;
if (!usesWildcardTypes(options)) {
return options.types ?? [];
}

// Walk the primary type lookup locations
const result: string[] = [];
const wildcardMatches: string[] = [];
if (host.directoryExists && host.getDirectories) {
const typeRoots = getEffectiveTypeRoots(options, host);
if (typeRoots) {
Expand All @@ -833,15 +835,18 @@ export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: M
// At this stage, skip results with leading dot.
if (baseFileName.charCodeAt(0) !== CharacterCodes.dot) {
// Return just the type directive names
result.push(baseFileName);
wildcardMatches.push(baseFileName);
}
}
}
}
}
}
}
return result;

// Order potentially matters in program construction, so substitute
// in the wildcard in the position it was specified in the types array
return deduplicate(flatten(options.types.map(t => t === "*" ? wildcardMatches : t)), equateValues);
}

export interface TypeReferenceDirectiveResolutionCache extends PerDirectoryResolutionCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>, NonRelativeNameResolutionCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>, PackageJsonInfoCache {
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/programDiagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import {
removeSuffix,
SourceFile,
TsConfigSourceFile,
usesWildcardTypes,
} from "./_namespaces/ts.js";

interface FileReasonToChainCache {
Expand Down Expand Up @@ -400,7 +401,7 @@ export function createProgramDiagnostics(getCompilerOptionsObjectLiteralSyntax:
) :
undefined;
case FileIncludeKind.AutomaticTypeDirectiveFile:
if (!options.types) return undefined;
if (usesWildcardTypes(options)) return undefined;
Comment thread
RyanCavanaugh marked this conversation as resolved.
Outdated
configFileNode = getOptionsSyntaxByArrayElementValue(getCompilerOptionsObjectLiteralSyntax(), "types", reason.typeReference);
Comment thread
RyanCavanaugh marked this conversation as resolved.
Outdated
message = Diagnostics.File_is_entry_point_of_type_library_specified_here;
break;
Expand Down
8 changes: 8 additions & 0 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8971,6 +8971,14 @@ export function importSyntaxAffectsModuleResolution(options: CompilerOptions): b
|| getResolvePackageJsonImports(options);
}

/**
* @internal
* Returns true if this option's types array includes "*"
*/
export function usesWildcardTypes(options: CompilerOptions): options is CompilerOptions & { types: string[]; } {
Comment thread
RyanCavanaugh marked this conversation as resolved.
return some(options.types, t => t === "*");
}

type CompilerOptionKeys = keyof { [K in keyof CompilerOptions as string extends K ? never : K]: any; };
function createComputedCompilerOptions<T extends Record<string, CompilerOptionKeys[]>>(
options: {
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ import {
sourceMapCommentRegExpDontCareLineStart,
sys,
System,
usesWildcardTypes,
WatchCompilerHost,
WatchCompilerHostOfConfigFile,
WatchCompilerHostOfFilesAndCompilerOptions,
Expand Down Expand Up @@ -529,7 +530,7 @@ export function fileIncludeReasonToDiagnostics(program: Program, reason: FileInc
options.outFile ? "--outFile" : "--out",
);
case FileIncludeKind.AutomaticTypeDirectiveFile: {
const messageAndArgs: DiagnosticAndArguments = options.types ?
Comment thread
sheetalkamat marked this conversation as resolved.
const messageAndArgs: DiagnosticAndArguments = !usesWildcardTypes(options) ?
reason.packageId ?
[Diagnostics.Entry_point_of_type_library_0_specified_in_compilerOptions_with_packageId_1, reason.typeReference, packageIdToString(reason.packageId)] :
[Diagnostics.Entry_point_of_type_library_0_specified_in_compilerOptions, reason.typeReference] :
Expand Down
3 changes: 2 additions & 1 deletion src/jsTyping/jsTyping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
some,
toFileNameLowerCase,
TypeAcquisition,
usesWildcardTypes,
Version,
versionMajorMinor,
} from "./_namespaces/ts.js";
Expand Down Expand Up @@ -133,7 +134,7 @@ export function discoverTypings(
const exclude = typeAcquisition.exclude || [];

// Directories to search for package.json, bower.json and other typing information
if (!compilerOptions.types) {
if (usesWildcardTypes(compilerOptions)) {
Comment thread
RyanCavanaugh marked this conversation as resolved.
Outdated
const possibleSearchDirs = new Set(fileNames.map(getDirectoryPath));
possibleSearchDirs.add(projectRootPath);
possibleSearchDirs.forEach(searchDir => {
Expand Down
Loading
Loading