Skip to content

Commit 9549c23

Browse files
committed
Merge branch 'main' into tsgo-port-restore-es5-main
2 parents 5c6162f + f09a0e5 commit 9549c23

File tree

1,876 files changed

+5262
-58729
lines changed

Some content is hidden

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

1,876 files changed

+5262
-58729
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -31,71 +31,60 @@ jobs:
3131
fail-fast: ${{ github.event_name == 'merge_group' }}
3232
matrix:
3333
config:
34-
# Main builds
34+
# PRs only check the newest and oldest Node versions.
35+
# macOS only ever checks the neest and oldest Node versions, but never in PR runs.
3536
- os: ubuntu-latest
3637
node-version: '24'
3738
bundle: true
38-
39-
# Other builds (skipped in merge queues)
4039
- os: windows-latest
4140
node-version: '24'
4241
bundle: true
4342
skip: ${{ github.event_name == 'merge_group' }}
4443
- os: macos-latest
4544
node-version: '24'
4645
bundle: true
47-
skip: ${{ github.event_name == 'merge_group' }}
46+
skip: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
47+
4848
- os: ubuntu-latest
4949
node-version: '22'
5050
bundle: true
51-
skip: ${{ github.event_name == 'merge_group' }}
51+
skip: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
5252
- os: windows-latest
5353
node-version: '22'
5454
bundle: true
55-
skip: ${{ github.event_name == 'merge_group' }}
56-
# Skip macOS for this version; resources are limited.
57-
# - os: macos-latest
58-
# node-version: '22'
59-
# bundle: true
60-
# skip: ${{ github.event_name == 'merge_group' }}
55+
skip: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
56+
6157
- os: ubuntu-latest
6258
node-version: '20'
6359
bundle: true
64-
skip: ${{ github.event_name == 'merge_group' }}
60+
skip: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
6561
- os: windows-latest
6662
node-version: '20'
6763
bundle: true
68-
skip: ${{ github.event_name == 'merge_group' }}
69-
# Skip macOS for this version; resources are limited.
70-
# - os: macos-latest
71-
# node-version: '20'
72-
# bundle: true
73-
# skip: ${{ github.event_name == 'merge_group' }}
64+
skip: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
65+
7466
- os: ubuntu-latest
7567
node-version: '18'
7668
bundle: true
77-
skip: ${{ github.event_name == 'merge_group' }}
69+
skip: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
7870
- os: windows-latest
7971
node-version: '18'
8072
bundle: true
81-
skip: ${{ github.event_name == 'merge_group' }}
82-
# Skip macOS for this version; resources are limited.
83-
# - os: macos-latest
84-
# node-version: '18'
85-
# bundle: true
86-
# skip: ${{ github.event_name == 'merge_group' }}
73+
skip: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
74+
8775
- os: ubuntu-latest
8876
node-version: '16'
8977
bundle: true
90-
skip: ${{ github.event_name == 'merge_group' }}
78+
skip: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
9179
- os: windows-latest
9280
node-version: '16'
9381
bundle: true
94-
skip: ${{ github.event_name == 'merge_group' }}
82+
skip: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
9583
- os: macos-latest
9684
node-version: '16'
9785
bundle: true
98-
skip: ${{ github.event_name == 'merge_group' }}
86+
skip: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
87+
9988
- os: ubuntu-latest
10089
node-version: '14'
10190
bundle: true
@@ -104,12 +93,9 @@ jobs:
10493
node-version: '14'
10594
bundle: true
10695
skip: ${{ github.event_name == 'merge_group' }}
107-
# No Node 14 on ARM macOS
108-
# - os: macos-latest
109-
# node-version: '14'
110-
# bundle: true
111-
# skip: ${{ github.event_name == 'merge_group' }}
96+
# Node 14 does not support macOS ARM.
11297

98+
# --no-bundle build
11399
- os: ubuntu-latest
114100
node-version: 'lts/*'
115101
bundle: false

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,
@@ -1124,6 +1125,7 @@ import {
11241125
UnionType,
11251126
UnionTypeNode,
11261127
UniqueESSymbolType,
1128+
usesWildcardTypes,
11271129
usingSingleLineStringWriter,
11281130
VariableDeclaration,
11291131
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

@@ -27699,27 +27701,29 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2769927701
case "console":
2770027702
return Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom;
2770127703
case "$":
27702-
return compilerOptions.types
27703-
? 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
27704-
: Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery;
27704+
return usesWildcardTypes(compilerOptions)
27705+
? Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery
27706+
: 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;
27707+
case "beforeEach":
2770527708
case "describe":
2770627709
case "suite":
2770727710
case "it":
2770827711
case "test":
27709-
return compilerOptions.types
27710-
? 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
27711-
: 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;
27712+
return usesWildcardTypes(compilerOptions)
27713+
? 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
27714+
: 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;
2771227715
case "process":
2771327716
case "require":
2771427717
case "Buffer":
2771527718
case "module":
27716-
return compilerOptions.types
27717-
? 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
27718-
: Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode;
27719+
case "NodeJS":
27720+
return usesWildcardTypes(compilerOptions)
27721+
? Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode
27722+
: 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;
2771927723
case "Bun":
27720-
return compilerOptions.types
27721-
? 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
27722-
: Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun;
27724+
return usesWildcardTypes(compilerOptions)
27725+
? Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun
27726+
: 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;
2772327727
case "Map":
2772427728
case "Set":
2772527729
case "Promise":
@@ -27754,6 +27758,20 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2775427758
}
2775527759
}
2775627760

27761+
function getCannotResolveModuleNameErrorForSpecificModule(moduleName: Expression): DiagnosticMessage | undefined {
27762+
if (moduleName.kind === SyntaxKind.StringLiteral) {
27763+
if (nodeCoreModules.has((moduleName as StringLiteral).text)) {
27764+
if (usesWildcardTypes(compilerOptions)) {
27765+
return Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode;
27766+
}
27767+
else {
27768+
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;
27769+
}
27770+
}
27771+
}
27772+
return undefined;
27773+
}
27774+
2775727775
function getResolvedSymbol(node: Identifier): Symbol {
2775827776
const links = getNodeLinks(node);
2775927777
if (!links.resolvedSymbol) {

src/compiler/commandLineParser.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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: "noImplicitThis",
@@ -969,7 +969,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
969969
strictFlag: true,
970970
category: Diagnostics.Type_Checking,
971971
description: Diagnostics.Enable_error_reporting_when_this_is_given_the_type_any,
972-
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
972+
defaultValueDescription: Diagnostics.true_unless_strict_is_false,
973973
},
974974
{
975975
name: "useUnknownInCatchVariables",
@@ -979,7 +979,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
979979
strictFlag: true,
980980
category: Diagnostics.Type_Checking,
981981
description: Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
982-
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
982+
defaultValueDescription: Diagnostics.true_unless_strict_is_false,
983983
},
984984
{
985985
name: "alwaysStrict",

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 {

src/compiler/program.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4553,6 +4553,9 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro
45534553
if (options.module === ModuleKind.None || options.module === ModuleKind.AMD || options.module === ModuleKind.UMD || options.module === ModuleKind.System) {
45544554
createDeprecatedDiagnostic("module", ModuleKind[options.module], /*useInstead*/ undefined, /*related*/ undefined);
45554555
}
4556+
if (options.downlevelIteration !== undefined) {
4557+
createDeprecatedDiagnostic("downlevelIteration");
4558+
}
45564559
});
45574560
}
45584561

src/compiler/programDiagnostics.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import {
5252
removeSuffix,
5353
SourceFile,
5454
TsConfigSourceFile,
55+
usesWildcardTypes,
5556
} from "./_namespaces/ts.js";
5657

5758
interface FileReasonToChainCache {
@@ -400,8 +401,8 @@ export function createProgramDiagnostics(getCompilerOptionsObjectLiteralSyntax:
400401
) :
401402
undefined;
402403
case FileIncludeKind.AutomaticTypeDirectiveFile:
403-
if (!options.types) return undefined;
404-
configFileNode = getOptionsSyntaxByArrayElementValue(getCompilerOptionsObjectLiteralSyntax(), "types", reason.typeReference);
404+
configFileNode = getOptionsSyntaxByArrayElementValue(getCompilerOptionsObjectLiteralSyntax(), "types", usesWildcardTypes(options) ? "*" : reason.typeReference);
405+
405406
message = Diagnostics.File_is_entry_point_of_type_library_specified_here;
406407
break;
407408
case FileIncludeKind.LibFile:

src/compiler/resolutionCache.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ import {
7474
StringLiteralLike,
7575
trace,
7676
updateResolutionField,
77+
usesWildcardTypes,
7778
WatchDirectoryFlags,
7879
} from "./_namespaces/ts.js";
7980

@@ -1667,7 +1668,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
16671668
*/
16681669
function updateTypeRootsWatch() {
16691670
const options = resolutionHost.getCompilationSettings();
1670-
if (options.types) {
1671+
if (!usesWildcardTypes(options)) {
16711672
// No need to do any watch since resolution cache is going to handle the failed lookups
16721673
// for the types added by this
16731674
closeTypeRootsWatch();

src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7440,6 +7440,7 @@ export interface CompilerOptions {
74407440
disableSourceOfProjectReferenceRedirect?: boolean;
74417441
disableSolutionSearching?: boolean;
74427442
disableReferencedProjectLoad?: boolean;
7443+
/** @deprecated */
74437444
downlevelIteration?: boolean;
74447445
emitBOM?: boolean;
74457446
emitDecoratorMetadata?: boolean;

0 commit comments

Comments
 (0)