typescript 5.7.0-dev.20240924 → 5.7.0-dev.20240926

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.7";
21
- var version = `${versionMajorMinor}.0-dev.20240924`;
21
+ var version = `${versionMajorMinor}.0-dev.20240926`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -6182,6 +6182,8 @@ var Diagnostics = {
6182
6182
  ),
6183
6183
  Type_only_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute: diag(1541, 1 /* Error */, "Type_only_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribut_1541", "Type-only import of an ECMAScript module from a CommonJS module must have a 'resolution-mode' attribute."),
6184
6184
  Type_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute: diag(1542, 1 /* Error */, "Type_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute_1542", "Type import of an ECMAScript module from a CommonJS module must have a 'resolution-mode' attribute."),
6185
+ Importing_a_JSON_file_into_an_ECMAScript_module_requires_a_type_Colon_json_import_attribute_when_module_is_set_to_0: diag(1543, 1 /* Error */, "Importing_a_JSON_file_into_an_ECMAScript_module_requires_a_type_Colon_json_import_attribute_when_mod_1543", `Importing a JSON file into an ECMAScript module requires a 'type: "json"' import attribute when 'module' is set to '{0}'.`),
6186
+ Named_imports_from_a_JSON_file_into_an_ECMAScript_module_are_not_allowed_when_module_is_set_to_0: diag(1544, 1 /* Error */, "Named_imports_from_a_JSON_file_into_an_ECMAScript_module_are_not_allowed_when_module_is_set_to_0_1544", "Named imports from a JSON file into an ECMAScript module are not allowed when 'module' is set to '{0}'."),
6185
6187
  The_types_of_0_are_incompatible_between_these_types: diag(2200, 1 /* Error */, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
6186
6188
  The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, 1 /* Error */, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
6187
6189
  Call_signature_return_types_0_and_1_are_incompatible: diag(
@@ -6753,6 +6755,8 @@ var Diagnostics = {
6753
6755
  This_expression_is_always_nullish: diag(2871, 1 /* Error */, "This_expression_is_always_nullish_2871", "This expression is always nullish."),
6754
6756
  This_kind_of_expression_is_always_truthy: diag(2872, 1 /* Error */, "This_kind_of_expression_is_always_truthy_2872", "This kind of expression is always truthy."),
6755
6757
  This_kind_of_expression_is_always_falsy: diag(2873, 1 /* Error */, "This_kind_of_expression_is_always_falsy_2873", "This kind of expression is always falsy."),
6758
+ This_JSX_tag_requires_0_to_be_in_scope_but_it_could_not_be_found: diag(2874, 1 /* Error */, "This_JSX_tag_requires_0_to_be_in_scope_but_it_could_not_be_found_2874", "This JSX tag requires '{0}' to be in scope, but it could not be found."),
6759
+ This_JSX_tag_requires_the_module_path_0_to_exist_but_none_could_be_found_Make_sure_you_have_types_for_the_appropriate_package_installed: diag(2875, 1 /* Error */, "This_JSX_tag_requires_the_module_path_0_to_exist_but_none_could_be_found_Make_sure_you_have_types_fo_2875", "This JSX tag requires the module path '{0}' to exist, but none could be found. Make sure you have types for the appropriate package installed."),
6756
6760
  Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
6757
6761
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
6758
6762
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -35596,9 +35600,10 @@ function getDeclarationFileExtension(fileName) {
35596
35600
  return standardExtension;
35597
35601
  }
35598
35602
  if (fileExtensionIs(fileName, ".ts" /* Ts */)) {
35599
- const index = getBaseFileName(fileName).lastIndexOf(".d.");
35603
+ const baseName = getBaseFileName(fileName);
35604
+ const index = baseName.lastIndexOf(".d.");
35600
35605
  if (index >= 0) {
35601
- return fileName.substring(index);
35606
+ return baseName.substring(index);
35602
35607
  }
35603
35608
  }
35604
35609
  return void 0;
@@ -47820,10 +47825,19 @@ function createTypeChecker(host) {
47820
47825
  function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
47821
47826
  return usageMode === 99 /* ESNext */ && targetMode === 1 /* CommonJS */;
47822
47827
  }
47823
- function isOnlyImportableAsDefault(usage) {
47828
+ function isOnlyImportableAsDefault(usage, resolvedModule) {
47824
47829
  if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
47825
47830
  const usageMode = getEmitSyntaxForModuleSpecifierExpression(usage);
47826
- return usageMode === 99 /* ESNext */ && endsWith(usage.text, ".json" /* Json */);
47831
+ if (usageMode === 99 /* ESNext */) {
47832
+ resolvedModule ?? (resolvedModule = resolveExternalModuleName(
47833
+ usage,
47834
+ usage,
47835
+ /*ignoreErrors*/
47836
+ true
47837
+ ));
47838
+ const targetFile = resolvedModule && getSourceFileOfModule(resolvedModule);
47839
+ return targetFile && (isJsonSourceFile(targetFile) || getDeclarationFileExtension(targetFile.fileName) === ".d.json.ts");
47840
+ }
47827
47841
  }
47828
47842
  return false;
47829
47843
  }
@@ -47894,7 +47908,7 @@ function createTypeChecker(host) {
47894
47908
  if (!specifier) {
47895
47909
  return exportDefaultSymbol;
47896
47910
  }
47897
- const hasDefaultOnly = isOnlyImportableAsDefault(specifier);
47911
+ const hasDefaultOnly = isOnlyImportableAsDefault(specifier, moduleSymbol);
47898
47912
  const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, specifier);
47899
47913
  if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
47900
47914
  if (hasExportAssignmentSymbol(moduleSymbol) && !allowSyntheticDefaultImports) {
@@ -48096,12 +48110,14 @@ function createTypeChecker(host) {
48096
48110
  let symbolFromModule = getExportOfModule(targetSymbol, nameText, specifier, dontResolveAlias);
48097
48111
  if (symbolFromModule === void 0 && nameText === "default" /* Default */) {
48098
48112
  const file = (_a = moduleSymbol.declarations) == null ? void 0 : _a.find(isSourceFile);
48099
- if (isOnlyImportableAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
48113
+ if (isOnlyImportableAsDefault(moduleSpecifier, moduleSymbol) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
48100
48114
  symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
48101
48115
  }
48102
48116
  }
48103
48117
  const symbol = symbolFromModule && symbolFromVariable && symbolFromModule !== symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable;
48104
- if (!symbol) {
48118
+ if (isImportOrExportSpecifier(specifier) && isOnlyImportableAsDefault(moduleSpecifier, moduleSymbol) && nameText !== "default" /* Default */) {
48119
+ error(name, Diagnostics.Named_imports_from_a_JSON_file_into_an_ECMAScript_module_are_not_allowed_when_module_is_set_to_0, ModuleKind[moduleKind]);
48120
+ } else if (!symbol) {
48105
48121
  errorNoModuleMemberSymbol(moduleSymbol, targetSymbol, node, name);
48106
48122
  }
48107
48123
  return symbol;
@@ -48680,7 +48696,7 @@ function createTypeChecker(host) {
48680
48696
  return isStringLiteralLike(moduleReferenceExpression) ? resolveExternalModule(location, moduleReferenceExpression.text, moduleNotFoundError, !ignoreErrors ? moduleReferenceExpression : void 0, isForAugmentation) : void 0;
48681
48697
  }
48682
48698
  function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation = false) {
48683
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
48699
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
48684
48700
  if (errorNode && startsWith(moduleReference, "@types/")) {
48685
48701
  const diag2 = Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
48686
48702
  const withoutAtTypePrefix = removePrefix(moduleReference, "@types/");
@@ -48695,14 +48711,14 @@ function createTypeChecker(host) {
48695
48711
  return ambientModule;
48696
48712
  }
48697
48713
  const currentSourceFile = getSourceFileOfNode(location);
48698
- const contextSpecifier = isStringLiteralLike(location) ? location : ((_a = isModuleDeclaration(location) ? location : location.parent && isModuleDeclaration(location.parent) && location.parent.name === location ? location.parent : void 0) == null ? void 0 : _a.name) || ((_b = isLiteralImportTypeNode(location) ? location : void 0) == null ? void 0 : _b.argument.literal) || (isInJSFile(location) && isJSDocImportTag(location) ? location.moduleSpecifier : void 0) || (isVariableDeclaration(location) && location.initializer && isRequireCall(
48714
+ const contextSpecifier = isStringLiteralLike(location) ? location : ((_a = isModuleDeclaration(location) ? location : location.parent && isModuleDeclaration(location.parent) && location.parent.name === location ? location.parent : void 0) == null ? void 0 : _a.name) || ((_b = isLiteralImportTypeNode(location) ? location : void 0) == null ? void 0 : _b.argument.literal) || (isVariableDeclaration(location) && location.initializer && isRequireCall(
48699
48715
  location.initializer,
48700
48716
  /*requireStringLiteralLikeArgument*/
48701
48717
  true
48702
- ) ? location.initializer.arguments[0] : void 0) || ((_c = findAncestor(location, isImportCall)) == null ? void 0 : _c.arguments[0]) || ((_d = findAncestor(location, isImportDeclaration)) == null ? void 0 : _d.moduleSpecifier) || ((_e = findAncestor(location, isExternalModuleImportEqualsDeclaration)) == null ? void 0 : _e.moduleReference.expression) || ((_f = findAncestor(location, isExportDeclaration)) == null ? void 0 : _f.moduleSpecifier);
48718
+ ) ? location.initializer.arguments[0] : void 0) || ((_c = findAncestor(location, isImportCall)) == null ? void 0 : _c.arguments[0]) || ((_d = findAncestor(location, or(isImportDeclaration, isJSDocImportTag, isExportDeclaration))) == null ? void 0 : _d.moduleSpecifier) || ((_e = findAncestor(location, isExternalModuleImportEqualsDeclaration)) == null ? void 0 : _e.moduleReference.expression);
48703
48719
  const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? host.getModeForUsageLocation(currentSourceFile, contextSpecifier) : host.getDefaultResolutionModeForFile(currentSourceFile);
48704
48720
  const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions);
48705
- const resolvedModule = (_g = host.getResolvedModule(currentSourceFile, moduleReference, mode)) == null ? void 0 : _g.resolvedModule;
48721
+ const resolvedModule = (_f = host.getResolvedModule(currentSourceFile, moduleReference, mode)) == null ? void 0 : _f.resolvedModule;
48706
48722
  const resolutionDiagnostic = errorNode && resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule, currentSourceFile);
48707
48723
  const sourceFile = resolvedModule && (!resolutionDiagnostic || resolutionDiagnostic === Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set) && host.getSourceFile(resolvedModule.resolvedFileName);
48708
48724
  if (sourceFile) {
@@ -48710,7 +48726,7 @@ function createTypeChecker(host) {
48710
48726
  error(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
48711
48727
  }
48712
48728
  if (resolvedModule.resolvedUsingTsExtension && isDeclarationFileName(moduleReference)) {
48713
- const importOrExport = ((_h = findAncestor(location, isImportDeclaration)) == null ? void 0 : _h.importClause) || findAncestor(location, or(isImportEqualsDeclaration, isExportDeclaration));
48729
+ const importOrExport = ((_g = findAncestor(location, isImportDeclaration)) == null ? void 0 : _g.importClause) || findAncestor(location, or(isImportEqualsDeclaration, isExportDeclaration));
48714
48730
  if (errorNode && importOrExport && !importOrExport.isTypeOnly || findAncestor(location, isImportCall)) {
48715
48731
  error(
48716
48732
  errorNode,
@@ -48719,7 +48735,7 @@ function createTypeChecker(host) {
48719
48735
  );
48720
48736
  }
48721
48737
  } else if (resolvedModule.resolvedUsingTsExtension && !shouldAllowImportingTsExtension(compilerOptions, currentSourceFile.fileName)) {
48722
- const importOrExport = ((_i = findAncestor(location, isImportDeclaration)) == null ? void 0 : _i.importClause) || findAncestor(location, or(isImportEqualsDeclaration, isExportDeclaration));
48738
+ const importOrExport = ((_h = findAncestor(location, isImportDeclaration)) == null ? void 0 : _h.importClause) || findAncestor(location, or(isImportEqualsDeclaration, isExportDeclaration));
48723
48739
  if (errorNode && !((importOrExport == null ? void 0 : importOrExport.isTypeOnly) || findAncestor(location, isImportTypeNode))) {
48724
48740
  const tsExtension = Debug.checkDefined(tryExtractTSExtension(moduleReference));
48725
48741
  error(errorNode, Diagnostics.An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled, tsExtension);
@@ -48749,7 +48765,7 @@ function createTypeChecker(host) {
48749
48765
  if (ext === ".ts" /* Ts */ || ext === ".js" /* Js */ || ext === ".tsx" /* Tsx */ || ext === ".jsx" /* Jsx */) {
48750
48766
  diagnosticDetails = createModeMismatchDetails(currentSourceFile);
48751
48767
  }
48752
- const message = (overrideHost == null ? void 0 : overrideHost.kind) === 272 /* ImportDeclaration */ && ((_j = overrideHost.importClause) == null ? void 0 : _j.isTypeOnly) ? Diagnostics.Type_only_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute : (overrideHost == null ? void 0 : overrideHost.kind) === 205 /* ImportType */ ? Diagnostics.Type_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute : Diagnostics.The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead;
48768
+ const message = (overrideHost == null ? void 0 : overrideHost.kind) === 272 /* ImportDeclaration */ && ((_i = overrideHost.importClause) == null ? void 0 : _i.isTypeOnly) ? Diagnostics.Type_only_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute : (overrideHost == null ? void 0 : overrideHost.kind) === 205 /* ImportType */ ? Diagnostics.Type_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute : Diagnostics.The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead;
48753
48769
  diagnostics.add(createDiagnosticForNodeFromMessageChain(
48754
48770
  getSourceFileOfNode(errorNode),
48755
48771
  errorNode,
@@ -48812,14 +48828,14 @@ function createTypeChecker(host) {
48812
48828
  error(errorNode, Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
48813
48829
  } else if (mode === 99 /* ESNext */ && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) {
48814
48830
  const absoluteRef = getNormalizedAbsolutePath(moduleReference, getDirectoryPath(currentSourceFile.path));
48815
- const suggestedExt = (_k = suggestedExtensions.find(([actualExt, _importExt]) => host.fileExists(absoluteRef + actualExt))) == null ? void 0 : _k[1];
48831
+ const suggestedExt = (_j = suggestedExtensions.find(([actualExt, _importExt]) => host.fileExists(absoluteRef + actualExt))) == null ? void 0 : _j[1];
48816
48832
  if (suggestedExt) {
48817
48833
  error(errorNode, Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt);
48818
48834
  } else {
48819
48835
  error(errorNode, Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path);
48820
48836
  }
48821
48837
  } else {
48822
- if ((_l = host.getResolvedModule(currentSourceFile, moduleReference, mode)) == null ? void 0 : _l.alternateResult) {
48838
+ if ((_k = host.getResolvedModule(currentSourceFile, moduleReference, mode)) == null ? void 0 : _k.alternateResult) {
48823
48839
  const errorInfo = createModuleNotFoundChain(currentSourceFile, host, moduleReference, mode, moduleReference);
48824
48840
  errorOrSuggestion(
48825
48841
  /*isError*/
@@ -52018,7 +52034,13 @@ function createTypeChecker(host) {
52018
52034
  if (typeFromTypeNode === type) {
52019
52035
  return true;
52020
52036
  }
52021
- if (annotatedDeclaration && (isParameter(annotatedDeclaration) || isPropertySignature(annotatedDeclaration) || isPropertyDeclaration(annotatedDeclaration)) && annotatedDeclaration.questionToken) {
52037
+ if (!annotatedDeclaration) {
52038
+ return false;
52039
+ }
52040
+ if ((isPropertySignature(annotatedDeclaration) || isPropertyDeclaration(annotatedDeclaration)) && annotatedDeclaration.questionToken) {
52041
+ return getTypeWithFacts(type, 524288 /* NEUndefined */) === typeFromTypeNode;
52042
+ }
52043
+ if (isParameter(annotatedDeclaration) && hasEffectiveQuestionToken(annotatedDeclaration)) {
52022
52044
  return getTypeWithFacts(type, 524288 /* NEUndefined */) === typeFromTypeNode;
52023
52045
  }
52024
52046
  return false;
@@ -52979,7 +53001,9 @@ function createTypeChecker(host) {
52979
53001
  const skipMembershipCheck = !isPrivate;
52980
53002
  if (skipMembershipCheck || !!length(symbol.declarations) && some(symbol.declarations, (d) => !!findAncestor(d, (n) => n === enclosingDeclaration))) {
52981
53003
  const scopeCleanup = cloneNodeBuilderContext(context);
53004
+ context.tracker.pushErrorFallbackNode(find(symbol.declarations, (d) => getSourceFileOfNode(d) === context.enclosingFile));
52982
53005
  serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
53006
+ context.tracker.popErrorFallbackNode();
52983
53007
  scopeCleanup();
52984
53008
  }
52985
53009
  }
@@ -56982,8 +57006,13 @@ function createTypeChecker(host) {
56982
57006
  if (left.typeParameters && right.typeParameters) {
56983
57007
  paramMapper = createTypeMapper(right.typeParameters, left.typeParameters);
56984
57008
  }
57009
+ let flags = (left.flags | right.flags) & (167 /* PropagatingFlags */ & ~1 /* HasRestParameter */);
56985
57010
  const declaration = left.declaration;
56986
57011
  const params = combineUnionParameters(left, right, paramMapper);
57012
+ const lastParam = lastOrUndefined(params);
57013
+ if (lastParam && getCheckFlags(lastParam) & 32768 /* RestParameter */) {
57014
+ flags |= 1 /* HasRestParameter */;
57015
+ }
56987
57016
  const thisParam = combineUnionThisParam(left.thisParameter, right.thisParameter, paramMapper);
56988
57017
  const minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount);
56989
57018
  const result = createSignature(
@@ -56996,7 +57025,7 @@ function createTypeChecker(host) {
56996
57025
  /*resolvedTypePredicate*/
56997
57026
  void 0,
56998
57027
  minArgCount,
56999
- (left.flags | right.flags) & 167 /* PropagatingFlags */
57028
+ flags
57000
57029
  );
57001
57030
  result.compositeKind = 1048576 /* Union */;
57002
57031
  result.compositeSignatures = concatenate(left.compositeKind !== 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]);
@@ -70482,7 +70511,7 @@ function createTypeChecker(host) {
70482
70511
  }
70483
70512
  function markJsxAliasReferenced(node) {
70484
70513
  if (!getJsxNamespaceContainerForImplicitImport(node)) {
70485
- const jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? Diagnostics.Cannot_find_name_0 : void 0;
70514
+ const jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? Diagnostics.This_JSX_tag_requires_0_to_be_in_scope_but_it_could_not_be_found : void 0;
70486
70515
  const jsxFactoryNamespace = getJsxNamespace(node);
70487
70516
  const jsxFactoryLocation = isJsxOpeningLikeElement(node) ? node.tagName : node;
70488
70517
  let jsxFactorySym;
@@ -72429,13 +72458,14 @@ function createTypeChecker(host) {
72429
72458
  const paramName = leftName === rightName ? leftName : !leftName ? rightName : !rightName ? leftName : void 0;
72430
72459
  const paramSymbol = createSymbol(
72431
72460
  1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0),
72432
- paramName || `arg${i}`
72461
+ paramName || `arg${i}`,
72462
+ isRestParam ? 32768 /* RestParameter */ : isOptional ? 16384 /* OptionalParameter */ : 0
72433
72463
  );
72434
72464
  paramSymbol.links.type = isRestParam ? createArrayType(unionParamType) : unionParamType;
72435
72465
  params[i] = paramSymbol;
72436
72466
  }
72437
72467
  if (needsExtraRestElement) {
72438
- const restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args");
72468
+ const restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args", 32768 /* RestParameter */);
72439
72469
  restParamSymbol.links.type = createArrayType(getTypeAtPosition(shorter, longestCount));
72440
72470
  if (shorter === right) {
72441
72471
  restParamSymbol.links.type = instantiateType(restParamSymbol.links.type, mapper);
@@ -72450,8 +72480,13 @@ function createTypeChecker(host) {
72450
72480
  if (left.typeParameters && right.typeParameters) {
72451
72481
  paramMapper = createTypeMapper(right.typeParameters, left.typeParameters);
72452
72482
  }
72483
+ let flags = (left.flags | right.flags) & (167 /* PropagatingFlags */ & ~1 /* HasRestParameter */);
72453
72484
  const declaration = left.declaration;
72454
72485
  const params = combineIntersectionParameters(left, right, paramMapper);
72486
+ const lastParam = lastOrUndefined(params);
72487
+ if (lastParam && getCheckFlags(lastParam) & 32768 /* RestParameter */) {
72488
+ flags |= 1 /* HasRestParameter */;
72489
+ }
72455
72490
  const thisParam = combineIntersectionThisParam(left.thisParameter, right.thisParameter, paramMapper);
72456
72491
  const minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount);
72457
72492
  const result = createSignature(
@@ -72464,7 +72499,7 @@ function createTypeChecker(host) {
72464
72499
  /*resolvedTypePredicate*/
72465
72500
  void 0,
72466
72501
  minArgCount,
72467
- (left.flags | right.flags) & 167 /* PropagatingFlags */
72502
+ flags
72468
72503
  );
72469
72504
  result.compositeKind = 2097152 /* Intersection */;
72470
72505
  result.compositeSignatures = concatenate(left.compositeKind === 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]);
@@ -73192,7 +73227,7 @@ function createTypeChecker(host) {
73192
73227
  return void 0;
73193
73228
  }
73194
73229
  const isClassic = getEmitModuleResolutionKind(compilerOptions) === 1 /* Classic */;
73195
- const errorMessage = isClassic ? Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_nodenext_or_to_add_aliases_to_the_paths_option : Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations;
73230
+ const errorMessage = isClassic ? Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_nodenext_or_to_add_aliases_to_the_paths_option : Diagnostics.This_JSX_tag_requires_the_module_path_0_to_exist_but_none_could_be_found_Make_sure_you_have_types_for_the_appropriate_package_installed;
73196
73231
  const specifier = getJSXRuntimeImportSpecifier(file, runtimeImportSpecifier);
73197
73232
  const mod = resolveExternalModule(specifier || location, runtimeImportSpecifier, errorMessage, location);
73198
73233
  const result = mod && mod !== unknownSymbol ? getMergedSymbol(resolveSymbol(mod)) : void 0;
@@ -84619,6 +84654,7 @@ function createTypeChecker(host) {
84619
84654
  grammarErrorOnFirstToken(node, Diagnostics.An_import_declaration_cannot_have_modifiers);
84620
84655
  }
84621
84656
  if (checkExternalImportOrExportDeclaration(node)) {
84657
+ let resolvedModule;
84622
84658
  const importClause = node.importClause;
84623
84659
  if (importClause && !checkGrammarImportClause(importClause)) {
84624
84660
  if (importClause.name) {
@@ -84631,18 +84667,27 @@ function createTypeChecker(host) {
84631
84667
  checkExternalEmitHelpers(node, 65536 /* ImportStar */);
84632
84668
  }
84633
84669
  } else {
84634
- const moduleExisted = resolveExternalModuleName(node, node.moduleSpecifier);
84635
- if (moduleExisted) {
84670
+ resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
84671
+ if (resolvedModule) {
84636
84672
  forEach(importClause.namedBindings.elements, checkImportBinding);
84637
84673
  }
84638
84674
  }
84639
84675
  }
84676
+ if (isOnlyImportableAsDefault(node.moduleSpecifier, resolvedModule) && !hasTypeJsonImportAttribute(node)) {
84677
+ error(node.moduleSpecifier, Diagnostics.Importing_a_JSON_file_into_an_ECMAScript_module_requires_a_type_Colon_json_import_attribute_when_module_is_set_to_0, ModuleKind[moduleKind]);
84678
+ }
84640
84679
  } else if (noUncheckedSideEffectImports && !importClause) {
84641
84680
  void resolveExternalModuleName(node, node.moduleSpecifier);
84642
84681
  }
84643
84682
  }
84644
84683
  checkImportAttributes(node);
84645
84684
  }
84685
+ function hasTypeJsonImportAttribute(node) {
84686
+ return !!node.attributes && node.attributes.elements.some((attr) => {
84687
+ var _a;
84688
+ return getTextOfIdentifierOrLiteral(attr.name) === "type" && ((_a = tryCast(attr.value, isStringLiteralLike)) == null ? void 0 : _a.text) === "json";
84689
+ });
84690
+ }
84646
84691
  function checkImportEqualsDeclaration(node) {
84647
84692
  if (checkGrammarModuleElementContext(node, isInJSFile(node) ? Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
84648
84693
  return;
@@ -85759,7 +85804,7 @@ function createTypeChecker(host) {
85759
85804
  } else if (isJSDocMemberName(name)) {
85760
85805
  return resolveJSDocMemberName(name);
85761
85806
  }
85762
- } else if (isTypeReferenceIdentifier(name)) {
85807
+ } else if (isEntityName(name) && isTypeReferenceIdentifier(name)) {
85763
85808
  const meaning = name.parent.kind === 183 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */;
85764
85809
  const symbol = resolveEntityName(
85765
85810
  name,
@@ -88969,6 +89014,14 @@ var SymbolTrackerImpl = class _SymbolTrackerImpl {
88969
89014
  this.inner.reportInferenceFallback(node);
88970
89015
  }
88971
89016
  }
89017
+ pushErrorFallbackNode(node) {
89018
+ var _a, _b;
89019
+ return (_b = (_a = this.inner) == null ? void 0 : _a.pushErrorFallbackNode) == null ? void 0 : _b.call(_a, node);
89020
+ }
89021
+ popErrorFallbackNode() {
89022
+ var _a, _b;
89023
+ return (_b = (_a = this.inner) == null ? void 0 : _a.popErrorFallbackNode) == null ? void 0 : _b.call(_a);
89024
+ }
88972
89025
  };
88973
89026
 
88974
89027
  // src/compiler/visitorPublic.ts
@@ -112125,6 +112178,7 @@ function transformDeclarations(context) {
112125
112178
  let suppressNewDiagnosticContexts;
112126
112179
  const { factory: factory2 } = context;
112127
112180
  const host = context.getEmitHost();
112181
+ let restoreFallbackNode = () => void 0;
112128
112182
  const symbolTracker = {
112129
112183
  trackSymbol,
112130
112184
  reportInaccessibleThisError,
@@ -112136,7 +112190,19 @@ function transformDeclarations(context) {
112136
112190
  moduleResolverHost: host,
112137
112191
  reportNonlocalAugmentation,
112138
112192
  reportNonSerializableProperty,
112139
- reportInferenceFallback
112193
+ reportInferenceFallback,
112194
+ pushErrorFallbackNode(node) {
112195
+ const currentFallback = errorFallbackNode;
112196
+ const currentRestore = restoreFallbackNode;
112197
+ restoreFallbackNode = () => {
112198
+ restoreFallbackNode = currentRestore;
112199
+ errorFallbackNode = currentFallback;
112200
+ };
112201
+ errorFallbackNode = node;
112202
+ },
112203
+ popErrorFallbackNode() {
112204
+ restoreFallbackNode();
112205
+ }
112140
112206
  };
112141
112207
  let errorNameNode;
112142
112208
  let errorFallbackNode;
@@ -120921,7 +120987,11 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120921
120987
  return (_a2 = resolvedTypeReferenceDirectiveNames == null ? void 0 : resolvedTypeReferenceDirectiveNames.get(file.path)) == null ? void 0 : _a2.get(typeDirectiveName, mode);
120922
120988
  }
120923
120989
  function getResolvedTypeReferenceDirectiveFromTypeReferenceDirective(typeRef, sourceFile) {
120924
- return getResolvedTypeReferenceDirective(sourceFile, typeRef.fileName, typeRef.resolutionMode || sourceFile.impliedNodeFormat);
120990
+ return getResolvedTypeReferenceDirective(
120991
+ sourceFile,
120992
+ typeRef.fileName,
120993
+ getModeForTypeReferenceDirectiveInFile(typeRef, sourceFile)
120994
+ );
120925
120995
  }
120926
120996
  function forEachResolvedModule(callback, file) {
120927
120997
  forEachResolution(resolvedModules, callback, file);
@@ -121308,10 +121378,11 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121308
121378
  const moduleNames = getModuleNames(newSourceFile);
121309
121379
  const resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
121310
121380
  (resolvedModulesProcessing ?? (resolvedModulesProcessing = /* @__PURE__ */ new Map())).set(newSourceFile.path, resolutions);
121381
+ const optionsForFile = getCompilerOptionsForFile(newSourceFile);
121311
121382
  const resolutionsChanged = hasChangesInResolutions(
121312
121383
  moduleNames,
121313
121384
  resolutions,
121314
- (name) => oldProgram.getResolvedModule(newSourceFile, name.text, getModeForUsageLocation2(newSourceFile, name)),
121385
+ (name) => oldProgram.getResolvedModule(newSourceFile, name.text, getModeForUsageLocationWorker(newSourceFile, name, optionsForFile)),
121315
121386
  moduleResolutionIsEqualTo
121316
121387
  );
121317
121388
  if (resolutionsChanged) structureIsReused = 1 /* SafeModules */;
@@ -121321,7 +121392,11 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121321
121392
  const typeReferenceResolutionsChanged = hasChangesInResolutions(
121322
121393
  typesReferenceDirectives,
121323
121394
  typeReferenceResolutions,
121324
- (name) => oldProgram.getResolvedTypeReferenceDirective(newSourceFile, getTypeReferenceResolutionName(name), getModeForFileReference(name, newSourceFile.impliedNodeFormat)),
121395
+ (name) => oldProgram.getResolvedTypeReferenceDirective(
121396
+ newSourceFile,
121397
+ getTypeReferenceResolutionName(name),
121398
+ getModeForTypeReferenceDirectiveInFile(name, newSourceFile)
121399
+ ),
121325
121400
  typeDirectiveIsEqualTo
121326
121401
  );
121327
121402
  if (typeReferenceResolutionsChanged) structureIsReused = 1 /* SafeModules */;
@@ -122482,8 +122557,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
122482
122557
  const ref = file.typeReferenceDirectives[index];
122483
122558
  const resolvedTypeReferenceDirective = resolutions[index];
122484
122559
  const fileName = ref.fileName;
122485
- resolutionsInFile.set(fileName, getModeForFileReference(ref, file.impliedNodeFormat), resolvedTypeReferenceDirective);
122486
- const mode = ref.resolutionMode || getDefaultResolutionModeForFile2(file);
122560
+ const mode = getModeForTypeReferenceDirectiveInFile(ref, file);
122561
+ resolutionsInFile.set(fileName, mode, resolvedTypeReferenceDirective);
122487
122562
  processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: 5 /* TypeReferenceDirective */, file: file.path, index });
122488
122563
  }
122489
122564
  }
@@ -123527,6 +123602,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123527
123602
  function shouldTransformImportCall(sourceFile) {
123528
123603
  return shouldTransformImportCallWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
123529
123604
  }
123605
+ function getModeForTypeReferenceDirectiveInFile(ref, sourceFile) {
123606
+ return ref.resolutionMode || getDefaultResolutionModeForFile2(sourceFile);
123607
+ }
123530
123608
  }
123531
123609
  function shouldTransformImportCallWorker(sourceFile, options) {
123532
123610
  const moduleKind = getEmitModuleKind(options);