Skip to content

Commit c3e2e60

Browse files
committed
Merge branch 'main' into feat/es2025-target
2 parents a684da6 + d67f0af commit c3e2e60

File tree

4,456 files changed

+29106
-61286
lines changed

Some content is hidden

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

4,456 files changed

+29106
-61286
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
@@ -911,6 +911,7 @@ import {
911911
NodeBuilderFlags,
912912
nodeCanBeDecorated,
913913
NodeCheckFlags,
914+
nodeCoreModules,
914915
NodeFlags,
915916
nodeHasName,
916917
nodeIsMissing,
@@ -1121,6 +1122,7 @@ import {
11211122
UnionType,
11221123
UnionTypeNode,
11231124
UniqueESSymbolType,
1125+
usesWildcardTypes,
11241126
usingSingleLineStringWriter,
11251127
VariableDeclaration,
11261128
VariableDeclarationList,
@@ -4708,9 +4710,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
47084710

47094711
function resolveExternalModuleName(location: Node, moduleReferenceExpression: Expression, ignoreErrors?: boolean, errorMessage?: DiagnosticMessage): Symbol | undefined {
47104712
const isClassic = getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Classic;
4711-
errorMessage ??= isClassic ?
4713+
errorMessage ??= getCannotResolveModuleNameErrorForSpecificModule(moduleReferenceExpression) ?? (isClassic ?
47124714
Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_nodenext_or_to_add_aliases_to_the_paths_option
4713-
: Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations;
4715+
: Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations);
47144716
return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : errorMessage, ignoreErrors);
47154717
}
47164718

@@ -27643,27 +27645,29 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2764327645
case "console":
2764427646
return Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom;
2764527647
case "$":
27646-
return compilerOptions.types
27647-
? 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
27648-
: Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery;
27648+
return usesWildcardTypes(compilerOptions)
27649+
? Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery
27650+
: 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;
27651+
case "beforeEach":
2764927652
case "describe":
2765027653
case "suite":
2765127654
case "it":
2765227655
case "test":
27653-
return compilerOptions.types
27654-
? 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
27655-
: 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;
27656+
return usesWildcardTypes(compilerOptions)
27657+
? 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
27658+
: 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;
2765627659
case "process":
2765727660
case "require":
2765827661
case "Buffer":
2765927662
case "module":
27660-
return compilerOptions.types
27661-
? 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
27662-
: Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode;
27663+
case "NodeJS":
27664+
return usesWildcardTypes(compilerOptions)
27665+
? Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode
27666+
: 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;
2766327667
case "Bun":
27664-
return compilerOptions.types
27665-
? 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
27666-
: Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun;
27668+
return usesWildcardTypes(compilerOptions)
27669+
? Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun
27670+
: 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;
2766727671
case "Map":
2766827672
case "Set":
2766927673
case "Promise":
@@ -27698,6 +27702,20 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2769827702
}
2769927703
}
2770027704

27705+
function getCannotResolveModuleNameErrorForSpecificModule(moduleName: Expression): DiagnosticMessage | undefined {
27706+
if (moduleName.kind === SyntaxKind.StringLiteral) {
27707+
if (nodeCoreModules.has((moduleName as StringLiteral).text)) {
27708+
if (usesWildcardTypes(compilerOptions)) {
27709+
return Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode;
27710+
}
27711+
else {
27712+
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;
27713+
}
27714+
}
27715+
}
27716+
return undefined;
27717+
}
27718+
2770127719
function getResolvedSymbol(node: Identifier): Symbol {
2770227720
const links = getNodeLinks(node);
2770327721
if (!links.resolvedSymbol) {

src/compiler/commandLineParser.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
916916
strictFlag: true,
917917
category: Diagnostics.Type_Checking,
918918
description: Diagnostics.Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type,
919-
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
919+
defaultValueDescription: Diagnostics.true_unless_strict_is_false,
920920
},
921921
{
922922
name: "strictNullChecks",
@@ -926,7 +926,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
926926
strictFlag: true,
927927
category: Diagnostics.Type_Checking,
928928
description: Diagnostics.When_type_checking_take_into_account_null_and_undefined,
929-
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
929+
defaultValueDescription: Diagnostics.true_unless_strict_is_false,
930930
},
931931
{
932932
name: "strictFunctionTypes",
@@ -936,7 +936,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
936936
strictFlag: true,
937937
category: Diagnostics.Type_Checking,
938938
description: Diagnostics.When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible,
939-
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
939+
defaultValueDescription: Diagnostics.true_unless_strict_is_false,
940940
},
941941
{
942942
name: "strictBindCallApply",
@@ -946,7 +946,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
946946
strictFlag: true,
947947
category: Diagnostics.Type_Checking,
948948
description: Diagnostics.Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function,
949-
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
949+
defaultValueDescription: Diagnostics.true_unless_strict_is_false,
950950
},
951951
{
952952
name: "strictPropertyInitialization",
@@ -956,7 +956,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
956956
strictFlag: true,
957957
category: Diagnostics.Type_Checking,
958958
description: Diagnostics.Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor,
959-
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
959+
defaultValueDescription: Diagnostics.true_unless_strict_is_false,
960960
},
961961
{
962962
name: "strictBuiltinIteratorReturn",
@@ -966,7 +966,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
966966
strictFlag: true,
967967
category: Diagnostics.Type_Checking,
968968
description: Diagnostics.Built_in_iterators_are_instantiated_with_a_TReturn_type_of_undefined_instead_of_any,
969-
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
969+
defaultValueDescription: Diagnostics.true_unless_strict_is_false,
970970
},
971971
{
972972
name: "noImplicitThis",
@@ -976,7 +976,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
976976
strictFlag: true,
977977
category: Diagnostics.Type_Checking,
978978
description: Diagnostics.Enable_error_reporting_when_this_is_given_the_type_any,
979-
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
979+
defaultValueDescription: Diagnostics.true_unless_strict_is_false,
980980
},
981981
{
982982
name: "useUnknownInCatchVariables",
@@ -986,18 +986,17 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
986986
strictFlag: true,
987987
category: Diagnostics.Type_Checking,
988988
description: Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
989-
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
989+
defaultValueDescription: Diagnostics.true_unless_strict_is_false,
990990
},
991991
{
992992
name: "alwaysStrict",
993993
type: "boolean",
994994
affectsSourceFile: true,
995995
affectsEmit: true,
996996
affectsBuildInfo: true,
997-
strictFlag: true,
998997
category: Diagnostics.Type_Checking,
999998
description: Diagnostics.Ensure_use_strict_is_always_emitted,
1000-
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
999+
defaultValueDescription: true,
10011000
},
10021001

10031002
// Additional Checks

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6607,7 +6607,7 @@
66076607
"code": 6903
66086608
},
66096609

6610-
"`false`, unless `strict` is set": {
6610+
"`true`, unless `strict` is `false`": {
66116611
"category": "Message",
66126612
"code": 6905
66136613
},

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)