Skip to content

Commit e369645

Browse files
committed
Merge branch 'main' into stable-type-ordering-flag
2 parents 0faa5b5 + d67f0af commit e369645

File tree

17,354 files changed

+156703
-114525
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

17,354 files changed

+156703
-114525
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -29,71 +29,60 @@ jobs:
2929
fail-fast: ${{ github.event_name == 'merge_group' }}
3030
matrix:
3131
config:
32-
# Main builds
32+
# PRs only check the newest and oldest Node versions.
33+
# macOS only ever checks the neest and oldest Node versions, but never in PR runs.
3334
- os: ubuntu-latest
3435
node-version: '24'
3536
bundle: true
36-
37-
# Other builds (skipped in merge queues)
3837
- os: windows-latest
3938
node-version: '24'
4039
bundle: true
4140
skip: ${{ github.event_name == 'merge_group' }}
4241
- os: macos-latest
4342
node-version: '24'
4443
bundle: true
45-
skip: ${{ github.event_name == 'merge_group' }}
44+
skip: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
45+
4646
- os: ubuntu-latest
4747
node-version: '22'
4848
bundle: true
49-
skip: ${{ github.event_name == 'merge_group' }}
49+
skip: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
5050
- os: windows-latest
5151
node-version: '22'
5252
bundle: true
53-
skip: ${{ github.event_name == 'merge_group' }}
54-
# Skip macOS for this version; resources are limited.
55-
# - os: macos-latest
56-
# node-version: '22'
57-
# bundle: true
58-
# skip: ${{ github.event_name == 'merge_group' }}
53+
skip: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
54+
5955
- os: ubuntu-latest
6056
node-version: '20'
6157
bundle: true
62-
skip: ${{ github.event_name == 'merge_group' }}
58+
skip: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
6359
- os: windows-latest
6460
node-version: '20'
6561
bundle: true
66-
skip: ${{ github.event_name == 'merge_group' }}
67-
# Skip macOS for this version; resources are limited.
68-
# - os: macos-latest
69-
# node-version: '20'
70-
# bundle: true
71-
# skip: ${{ github.event_name == 'merge_group' }}
62+
skip: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
63+
7264
- os: ubuntu-latest
7365
node-version: '18'
7466
bundle: true
75-
skip: ${{ github.event_name == 'merge_group' }}
67+
skip: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
7668
- os: windows-latest
7769
node-version: '18'
7870
bundle: true
79-
skip: ${{ github.event_name == 'merge_group' }}
80-
# Skip macOS for this version; resources are limited.
81-
# - os: macos-latest
82-
# node-version: '18'
83-
# bundle: true
84-
# skip: ${{ github.event_name == 'merge_group' }}
71+
skip: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
72+
8573
- os: ubuntu-latest
8674
node-version: '16'
8775
bundle: true
88-
skip: ${{ github.event_name == 'merge_group' }}
76+
skip: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
8977
- os: windows-latest
9078
node-version: '16'
9179
bundle: true
92-
skip: ${{ github.event_name == 'merge_group' }}
80+
skip: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
9381
- os: macos-latest
9482
node-version: '16'
9583
bundle: true
96-
skip: ${{ github.event_name == 'merge_group' }}
84+
skip: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
85+
9786
- os: ubuntu-latest
9887
node-version: '14'
9988
bundle: true
@@ -102,12 +91,9 @@ jobs:
10291
node-version: '14'
10392
bundle: true
10493
skip: ${{ github.event_name == 'merge_group' }}
105-
# No Node 14 on ARM macOS
106-
# - os: macos-latest
107-
# node-version: '14'
108-
# bundle: true
109-
# skip: ${{ github.event_name == 'merge_group' }}
94+
# Node 14 does not support macOS ARM.
11095

96+
# --no-bundle build
11197
- os: ubuntu-latest
11298
node-version: 'lts/*'
11399
bundle: false

src/compiler/binder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ import {
8282
FunctionExpression,
8383
FunctionLikeDeclaration,
8484
GetAccessorDeclaration,
85+
getAlwaysStrict,
8586
getAssignedExpandoInitializer,
8687
getAssignmentDeclarationKind,
8788
getAssignmentDeclarationPropertyAccessKind,
@@ -108,7 +109,6 @@ import {
108109
getSourceFileOfNode,
109110
getSourceTextOfNodeFromSourceFile,
110111
getSpanOfTokenAtPosition,
111-
getStrictOptionValue,
112112
getSymbolNameForPrivateIdentifier,
113113
getTextOfIdentifierOrLiteral,
114114
getThisContainer,
@@ -618,7 +618,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
618618
}
619619

620620
function bindInStrictMode(file: SourceFile, opts: CompilerOptions): boolean {
621-
if (getStrictOptionValue(opts, "alwaysStrict") && !file.isDeclarationFile) {
621+
if (getAlwaysStrict(opts) && !file.isDeclarationFile) {
622622
// bind in strict mode source files with alwaysStrict option
623623
return true;
624624
}

src/compiler/checker.ts

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@ import {
913913
NodeBuilderFlags,
914914
nodeCanBeDecorated,
915915
NodeCheckFlags,
916+
nodeCoreModules,
916917
NodeFlags,
917918
nodeHasName,
918919
nodeIsMissing,
@@ -1123,6 +1124,7 @@ import {
11231124
UnionType,
11241125
UnionTypeNode,
11251126
UniqueESSymbolType,
1127+
usesWildcardTypes,
11261128
usingSingleLineStringWriter,
11271129
VariableDeclaration,
11281130
VariableDeclarationList,
@@ -4713,9 +4715,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
47134715

47144716
function resolveExternalModuleName(location: Node, moduleReferenceExpression: Expression, ignoreErrors?: boolean, errorMessage?: DiagnosticMessage): Symbol | undefined {
47154717
const isClassic = getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Classic;
4716-
errorMessage ??= isClassic ?
4718+
errorMessage ??= getCannotResolveModuleNameErrorForSpecificModule(moduleReferenceExpression) ?? (isClassic ?
47174719
Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_nodenext_or_to_add_aliases_to_the_paths_option
4718-
: Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations;
4720+
: Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations);
47194721
return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : errorMessage, ignoreErrors);
47204722
}
47214723

@@ -27693,27 +27695,29 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2769327695
case "console":
2769427696
return Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom;
2769527697
case "$":
27696-
return compilerOptions.types
27697-
? 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
27698-
: Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery;
27698+
return usesWildcardTypes(compilerOptions)
27699+
? Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery
27700+
: 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;
27701+
case "beforeEach":
2769927702
case "describe":
2770027703
case "suite":
2770127704
case "it":
2770227705
case "test":
27703-
return compilerOptions.types
27704-
? 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
27705-
: 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;
27706+
return usesWildcardTypes(compilerOptions)
27707+
? 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
27708+
: 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;
2770627709
case "process":
2770727710
case "require":
2770827711
case "Buffer":
2770927712
case "module":
27710-
return compilerOptions.types
27711-
? 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
27712-
: Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode;
27713+
case "NodeJS":
27714+
return usesWildcardTypes(compilerOptions)
27715+
? Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode
27716+
: 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;
2771327717
case "Bun":
27714-
return compilerOptions.types
27715-
? 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
27716-
: Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun;
27718+
return usesWildcardTypes(compilerOptions)
27719+
? Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun
27720+
: 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;
2771727721
case "Map":
2771827722
case "Set":
2771927723
case "Promise":
@@ -27748,6 +27752,20 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2774827752
}
2774927753
}
2775027754

27755+
function getCannotResolveModuleNameErrorForSpecificModule(moduleName: Expression): DiagnosticMessage | undefined {
27756+
if (moduleName.kind === SyntaxKind.StringLiteral) {
27757+
if (nodeCoreModules.has((moduleName as StringLiteral).text)) {
27758+
if (usesWildcardTypes(compilerOptions)) {
27759+
return Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode;
27760+
}
27761+
else {
27762+
return 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;
27763+
}
27764+
}
27765+
}
27766+
return undefined;
27767+
}
27768+
2775127769
function getResolvedSymbol(node: Identifier): Symbol {
2775227770
const links = getNodeLinks(node);
2775327771
if (!links.resolvedSymbol) {

src/compiler/commandLineParser.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
899899
showInSimplifiedHelpView: true,
900900
category: Diagnostics.Type_Checking,
901901
description: Diagnostics.Enable_all_strict_type_checking_options,
902-
defaultValueDescription: false,
902+
defaultValueDescription: true,
903903
},
904904
{
905905
name: "noImplicitAny",
@@ -909,7 +909,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
909909
strictFlag: true,
910910
category: Diagnostics.Type_Checking,
911911
description: Diagnostics.Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type,
912-
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
912+
defaultValueDescription: Diagnostics.true_unless_strict_is_false,
913913
},
914914
{
915915
name: "strictNullChecks",
@@ -919,7 +919,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
919919
strictFlag: true,
920920
category: Diagnostics.Type_Checking,
921921
description: Diagnostics.When_type_checking_take_into_account_null_and_undefined,
922-
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
922+
defaultValueDescription: Diagnostics.true_unless_strict_is_false,
923923
},
924924
{
925925
name: "strictFunctionTypes",
@@ -929,7 +929,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
929929
strictFlag: true,
930930
category: Diagnostics.Type_Checking,
931931
description: Diagnostics.When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible,
932-
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
932+
defaultValueDescription: Diagnostics.true_unless_strict_is_false,
933933
},
934934
{
935935
name: "strictBindCallApply",
@@ -939,7 +939,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
939939
strictFlag: true,
940940
category: Diagnostics.Type_Checking,
941941
description: Diagnostics.Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function,
942-
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
942+
defaultValueDescription: Diagnostics.true_unless_strict_is_false,
943943
},
944944
{
945945
name: "strictPropertyInitialization",
@@ -949,7 +949,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
949949
strictFlag: true,
950950
category: Diagnostics.Type_Checking,
951951
description: Diagnostics.Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor,
952-
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
952+
defaultValueDescription: Diagnostics.true_unless_strict_is_false,
953953
},
954954
{
955955
name: "strictBuiltinIteratorReturn",
@@ -959,7 +959,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
959959
strictFlag: true,
960960
category: Diagnostics.Type_Checking,
961961
description: Diagnostics.Built_in_iterators_are_instantiated_with_a_TReturn_type_of_undefined_instead_of_any,
962-
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
962+
defaultValueDescription: Diagnostics.true_unless_strict_is_false,
963963
},
964964
{
965965
name: "stableTypeOrdering",
@@ -979,7 +979,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
979979
strictFlag: true,
980980
category: Diagnostics.Type_Checking,
981981
description: Diagnostics.Enable_error_reporting_when_this_is_given_the_type_any,
982-
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
982+
defaultValueDescription: Diagnostics.true_unless_strict_is_false,
983983
},
984984
{
985985
name: "useUnknownInCatchVariables",
@@ -989,18 +989,17 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
989989
strictFlag: true,
990990
category: Diagnostics.Type_Checking,
991991
description: Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
992-
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
992+
defaultValueDescription: Diagnostics.true_unless_strict_is_false,
993993
},
994994
{
995995
name: "alwaysStrict",
996996
type: "boolean",
997997
affectsSourceFile: true,
998998
affectsEmit: true,
999999
affectsBuildInfo: true,
1000-
strictFlag: true,
10011000
category: Diagnostics.Type_Checking,
10021001
description: Diagnostics.Ensure_use_strict_is_always_emitted,
1003-
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
1002+
defaultValueDescription: true,
10041003
},
10051004

10061005
// Additional Checks

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6611,7 +6611,7 @@
66116611
"code": 6903
66126612
},
66136613

6614-
"`false`, unless `strict` is set": {
6614+
"`true`, unless `strict` is `false`": {
66156615
"category": "Message",
66166616
"code": 6905
66176617
},

src/compiler/moduleNameResolver.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ import {
2626
emptyArray,
2727
endsWith,
2828
ensureTrailingDirectorySeparator,
29+
equateValues,
2930
every,
3031
Extension,
3132
extensionIsTS,
3233
fileExtensionIs,
3334
fileExtensionIsOneOf,
3435
filter,
3536
firstDefined,
37+
flatten,
3638
forEach,
3739
forEachAncestorDirectory,
3840
formatMessage,
@@ -105,6 +107,7 @@ import {
105107
tryExtractTSExtension,
106108
tryGetExtensionFromPath,
107109
tryParsePatterns,
110+
usesWildcardTypes,
108111
Version,
109112
version,
110113
versionMajorMinor,
@@ -803,18 +806,17 @@ export function resolvePackageNameToPackageJson(
803806
* Given a set of options, returns the set of type directive names
804807
* that should be included for this program automatically.
805808
* This list could either come from the config file,
806-
* or from enumerating the types root + initial secondary types lookup location.
809+
* and/or from enumerating the types root + initial secondary types lookup location given "*" compat wildcard.
807810
* More type directives might appear in the program later as a result of loading actual source files;
808811
* this list is only the set of defaults that are implicitly included.
809812
*/
810813
export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[] {
811-
// Use explicit type list from tsconfig.json
812-
if (options.types) {
813-
return options.types;
814+
if (!usesWildcardTypes(options)) {
815+
return options.types ?? [];
814816
}
815817

816818
// Walk the primary type lookup locations
817-
const result: string[] = [];
819+
const wildcardMatches: string[] = [];
818820
if (host.directoryExists && host.getDirectories) {
819821
const typeRoots = getEffectiveTypeRoots(options, host);
820822
if (typeRoots) {
@@ -833,15 +835,18 @@ export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: M
833835
// At this stage, skip results with leading dot.
834836
if (baseFileName.charCodeAt(0) !== CharacterCodes.dot) {
835837
// Return just the type directive names
836-
result.push(baseFileName);
838+
wildcardMatches.push(baseFileName);
837839
}
838840
}
839841
}
840842
}
841843
}
842844
}
843845
}
844-
return result;
846+
847+
// Order potentially matters in program construction, so substitute
848+
// in the wildcard in the position it was specified in the types array
849+
return deduplicate(flatten(options.types.map(t => t === "*" ? wildcardMatches : t)), equateValues);
845850
}
846851

847852
export interface TypeReferenceDirectiveResolutionCache extends PerDirectoryResolutionCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>, NonRelativeNameResolutionCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>, PackageJsonInfoCache {

0 commit comments

Comments
 (0)