@typescript-deploys/pr-build 5.2.0-pr-54507-7 → 5.2.0-pr-54546-4

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.2";
21
- var version = `${versionMajorMinor}.0-insiders.20230602`;
21
+ var version = `${versionMajorMinor}.0-insiders.20230605`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -6138,6 +6138,7 @@ var Diagnostics = {
6138
6138
  The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, 1 /* Error */, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
6139
6139
  Add_extends_constraint: diag(2211, 3 /* Message */, "Add_extends_constraint_2211", "Add `extends` constraint."),
6140
6140
  Add_extends_constraint_to_all_type_parameters: diag(2212, 3 /* Message */, "Add_extends_constraint_to_all_type_parameters_2212", "Add `extends` constraint to all type parameters"),
6141
+ The_project_root_is_ambiguous_but_is_required_to_determine_the_module_format_of_output_js_files_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2213, 1 /* Error */, "The_project_root_is_ambiguous_but_is_required_to_determine_the_module_format_of_output_js_files_Supp_2213", "The project root is ambiguous, but is required to determine the module format of output '.js' files. Supply the `rootDir` compiler option to disambiguate."),
6141
6142
  Duplicate_identifier_0: diag(2300, 1 /* Error */, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
6142
6143
  Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, 1 /* Error */, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
6143
6144
  Static_members_cannot_reference_class_type_parameters: diag(2302, 1 /* Error */, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."),
@@ -42658,10 +42659,11 @@ var CheckMode = /* @__PURE__ */ ((CheckMode3) => {
42658
42659
  CheckMode3[CheckMode3["Inferential"] = 2] = "Inferential";
42659
42660
  CheckMode3[CheckMode3["SkipContextSensitive"] = 4] = "SkipContextSensitive";
42660
42661
  CheckMode3[CheckMode3["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
42661
- CheckMode3[CheckMode3["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
42662
- CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
42663
- CheckMode3[CheckMode3["RestBindingElement"] = 64] = "RestBindingElement";
42664
- CheckMode3[CheckMode3["TypeOnly"] = 128] = "TypeOnly";
42662
+ CheckMode3[CheckMode3["SkipAddingIntraExpressionSites"] = 16] = "SkipAddingIntraExpressionSites";
42663
+ CheckMode3[CheckMode3["IsForSignatureHelp"] = 32] = "IsForSignatureHelp";
42664
+ CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 64] = "IsForStringLiteralArgumentCompletions";
42665
+ CheckMode3[CheckMode3["RestBindingElement"] = 128] = "RestBindingElement";
42666
+ CheckMode3[CheckMode3["TypeOnly"] = 256] = "TypeOnly";
42665
42667
  return CheckMode3;
42666
42668
  })(CheckMode || {});
42667
42669
  var SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
@@ -42941,9 +42943,9 @@ function createTypeChecker(host) {
42941
42943
  candidatesOutArray,
42942
42944
  /*argumentCount*/
42943
42945
  void 0,
42944
- 32 /* IsForStringLiteralArgumentCompletions */
42946
+ 64 /* IsForStringLiteralArgumentCompletions */
42945
42947
  )),
42946
- getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */)),
42948
+ getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 32 /* IsForSignatureHelp */)),
42947
42949
  getExpandedParameters,
42948
42950
  hasEffectiveRestParameter,
42949
42951
  containsArgumentsReference,
@@ -50898,7 +50900,7 @@ function createTypeChecker(host) {
50898
50900
  return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
50899
50901
  }
50900
50902
  function getTypeForBindingElement(declaration) {
50901
- const checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
50903
+ const checkMode = declaration.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */;
50902
50904
  const parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
50903
50905
  return parentType && getBindingElementTypeFromParentType(declaration, parentType);
50904
50906
  }
@@ -65798,7 +65800,7 @@ function createTypeChecker(host) {
65798
65800
  return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
65799
65801
  }
65800
65802
  function hasContextualTypeWithNoGenericTypes(node, checkMode) {
65801
- const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 64 /* RestBindingElement */ ? getContextualType(node, 8 /* SkipBindingPatterns */) : getContextualType(
65803
+ const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 128 /* RestBindingElement */ ? getContextualType(node, 8 /* SkipBindingPatterns */) : getContextualType(
65802
65804
  node,
65803
65805
  /*contextFlags*/
65804
65806
  void 0
@@ -66555,7 +66557,7 @@ function createTypeChecker(host) {
66555
66557
  function getContextualTypeForBindingElement(declaration, contextFlags) {
66556
66558
  const parent = declaration.parent.parent;
66557
66559
  const name = declaration.propertyName || declaration.name;
66558
- const parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) || parent.kind !== 207 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
66560
+ const parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) || parent.kind !== 207 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */);
66559
66561
  if (!parentType || isBindingPattern(name) || isComputedNonLiteralName(name))
66560
66562
  return void 0;
66561
66563
  if (parent.name.kind === 206 /* ArrayBindingPattern */) {
@@ -67604,7 +67606,9 @@ function createTypeChecker(host) {
67604
67606
  elementTypes.push(undefinedOrMissingType);
67605
67607
  elementFlags.push(2 /* Optional */);
67606
67608
  } else {
67607
- const type = checkExpressionForMutableLocation(e, checkMode, forceTuple);
67609
+ const shouldAddAsIntraExpressionInferenceSite = inTupleContext && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && isContextSensitive(e);
67610
+ const elementCheckMode = (checkMode || 0 /* Normal */) | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
67611
+ const type = checkExpressionForMutableLocation(e, elementCheckMode, forceTuple);
67608
67612
  elementTypes.push(addOptionality(
67609
67613
  type,
67610
67614
  /*isProperty*/
@@ -67612,7 +67616,7 @@ function createTypeChecker(host) {
67612
67616
  hasOmittedExpression
67613
67617
  ));
67614
67618
  elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
67615
- if (inTupleContext && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) {
67619
+ if (shouldAddAsIntraExpressionInferenceSite) {
67616
67620
  const inferenceContext = getInferenceContext(node);
67617
67621
  Debug.assert(inferenceContext);
67618
67622
  addIntraExpressionInferenceSite(inferenceContext, e, type);
@@ -67753,11 +67757,13 @@ function createTypeChecker(host) {
67753
67757
  let member = getSymbolOfDeclaration(memberDecl);
67754
67758
  const computedNameType = memberDecl.name && memberDecl.name.kind === 166 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
67755
67759
  if (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 303 /* ShorthandPropertyAssignment */ || isObjectLiteralMethod(memberDecl)) {
67756
- let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : (
67760
+ const shouldAddAsIntraExpressionInferenceSite = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 173 /* MethodDeclaration */) && isContextSensitive(memberDecl);
67761
+ const propCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
67762
+ let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, propCheckMode) : (
67757
67763
  // avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
67758
67764
  // for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
67759
67765
  // we don't want to say "could not find 'a'".
67760
- memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode)
67766
+ memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, propCheckMode) : checkObjectLiteralMethod(memberDecl, propCheckMode)
67761
67767
  );
67762
67768
  if (isInJavascript) {
67763
67769
  const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
@@ -67801,7 +67807,7 @@ function createTypeChecker(host) {
67801
67807
  prop.links.target = member;
67802
67808
  member = prop;
67803
67809
  allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
67804
- if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 173 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
67810
+ if (shouldAddAsIntraExpressionInferenceSite) {
67805
67811
  const inferenceContext = getInferenceContext(node);
67806
67812
  Debug.assert(inferenceContext);
67807
67813
  const inferenceNode = memberDecl.kind === 302 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
@@ -67974,7 +67980,9 @@ function createTypeChecker(host) {
67974
67980
  for (const attributeDecl of attributes.properties) {
67975
67981
  const member = attributeDecl.symbol;
67976
67982
  if (isJsxAttribute(attributeDecl)) {
67977
- const exprType = checkJsxAttribute(attributeDecl, checkMode);
67983
+ const shouldAddAsIntraExpressionInferenceSite = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && isContextSensitive(attributeDecl);
67984
+ const attributeCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
67985
+ const exprType = checkJsxAttribute(attributeDecl, attributeCheckMode);
67978
67986
  objectFlags |= getObjectFlags(exprType) & 458752 /* PropagatingFlags */;
67979
67987
  const attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName);
67980
67988
  attributeSymbol.declarations = member.declarations;
@@ -67995,7 +68003,7 @@ function createTypeChecker(host) {
67995
68003
  addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText);
67996
68004
  }
67997
68005
  }
67998
- if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(attributeDecl)) {
68006
+ if (shouldAddAsIntraExpressionInferenceSite) {
67999
68007
  const inferenceContext = getInferenceContext(attributes);
68000
68008
  Debug.assert(inferenceContext);
68001
68009
  const inferenceNode = attributeDecl.initializer.expression;
@@ -69613,7 +69621,7 @@ function createTypeChecker(host) {
69613
69621
  }
69614
69622
  for (let i = 0; i < argCount; i++) {
69615
69623
  const arg = args[i];
69616
- if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
69624
+ if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode & 64 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
69617
69625
  const paramType = getTypeAtPosition(signature, i);
69618
69626
  if (couldContainTypeVariables(paramType)) {
69619
69627
  const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
@@ -70226,12 +70234,12 @@ function createTypeChecker(host) {
70226
70234
  const args = getEffectiveCallArguments(node);
70227
70235
  const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
70228
70236
  let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
70229
- argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
70237
+ argCheckMode |= checkMode & 64 /* IsForStringLiteralArgumentCompletions */;
70230
70238
  let candidatesForArgumentError;
70231
70239
  let candidateForArgumentArityError;
70232
70240
  let candidateForTypeArgumentError;
70233
70241
  let result;
70234
- const signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 212 /* CallExpression */ && node.arguments.hasTrailingComma;
70242
+ const signatureHelpTrailingComma = !!(checkMode & 32 /* IsForSignatureHelp */) && node.kind === 212 /* CallExpression */ && node.arguments.hasTrailingComma;
70235
70243
  if (candidates.length > 1) {
70236
70244
  result = chooseOverload(candidates, subtypeRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
70237
70245
  }
@@ -70450,7 +70458,7 @@ function createTypeChecker(host) {
70450
70458
  continue;
70451
70459
  }
70452
70460
  if (argCheckMode) {
70453
- argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
70461
+ argCheckMode = checkMode & 64 /* IsForStringLiteralArgumentCompletions */;
70454
70462
  if (inferenceContext) {
70455
70463
  const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
70456
70464
  checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
@@ -73528,7 +73536,7 @@ function createTypeChecker(host) {
73528
73536
  case 36 /* ExclamationEqualsToken */:
73529
73537
  case 37 /* EqualsEqualsEqualsToken */:
73530
73538
  case 38 /* ExclamationEqualsEqualsToken */:
73531
- if (!(checkMode && checkMode & 128 /* TypeOnly */)) {
73539
+ if (!(checkMode && checkMode & 256 /* TypeOnly */)) {
73532
73540
  if (isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) {
73533
73541
  const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
73534
73542
  error(errorNode, Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
@@ -74187,7 +74195,7 @@ function createTypeChecker(host) {
74187
74195
  }
74188
74196
  }
74189
74197
  const startInvocationCount = flowInvocationCount;
74190
- const type = checkExpression(node, 128 /* TypeOnly */);
74198
+ const type = checkExpression(node, 256 /* TypeOnly */);
74191
74199
  if (flowInvocationCount !== startInvocationCount) {
74192
74200
  const cache = flowTypeCache || (flowTypeCache = []);
74193
74201
  cache[getNodeId(node)] = type;
@@ -76658,7 +76666,7 @@ function createTypeChecker(host) {
76658
76666
  checkComputedPropertyName(node.propertyName);
76659
76667
  }
76660
76668
  const parent = node.parent.parent;
76661
- const parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
76669
+ const parentCheckMode = node.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */;
76662
76670
  const parentType = getTypeForBindingElementParent(parent, parentCheckMode);
76663
76671
  const name = node.propertyName || node.name;
76664
76672
  if (parentType && !isBindingPattern(name)) {
@@ -107154,6 +107162,15 @@ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, get
107154
107162
  getDeclarationEmitExtensionForPath(inputFileName)
107155
107163
  );
107156
107164
  }
107165
+ function getOutputDeclarationFileNameWithoutConfigFile(inputFileName, options, ignoreCase, currentDirectory, getCommonSourceDirectory2) {
107166
+ const directory = options.declarationDir || options.outDir ? getNormalizedAbsolutePath(options.declarationDir || options.outDir, currentDirectory) : void 0;
107167
+ const outputPathWithoutChangedExtension = directory ? resolvePath(directory, getRelativePathFromDirectory(getCommonSourceDirectory2(), inputFileName, ignoreCase)) : inputFileName;
107168
+ const outputFileName = changeExtension(
107169
+ outputPathWithoutChangedExtension,
107170
+ getDeclarationEmitExtensionForPath(inputFileName)
107171
+ );
107172
+ return outputFileName;
107173
+ }
107157
107174
  function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory2) {
107158
107175
  if (configFile.options.emitDeclarationOnly)
107159
107176
  return void 0;
@@ -107164,6 +107181,18 @@ function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSou
107164
107181
  );
107165
107182
  return !isJsonFile || comparePaths(inputFileName, outputFileName, Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? outputFileName : void 0;
107166
107183
  }
107184
+ function getOutputJSFileNameWithoutConfigFile(inputFileName, options, ignoreCase, currentDirectory, getCommonSourceDirectory2) {
107185
+ if (options.emitDeclarationOnly)
107186
+ return void 0;
107187
+ const isJsonFile = fileExtensionIs(inputFileName, ".json" /* Json */);
107188
+ const outDir = options.outDir ? getNormalizedAbsolutePath(options.outDir, currentDirectory) : void 0;
107189
+ const outputPathWithoutChangedExtension = outDir ? resolvePath(outDir, getRelativePathFromDirectory(getCommonSourceDirectory2(), inputFileName, ignoreCase)) : inputFileName;
107190
+ const outputFileName = changeExtension(
107191
+ outputPathWithoutChangedExtension,
107192
+ getOutputExtension(inputFileName, options)
107193
+ );
107194
+ return !isJsonFile || !options.configFilePath || comparePaths(inputFileName, outputFileName, options.configFilePath, ignoreCase) !== 0 /* EqualTo */ ? outputFileName : void 0;
107195
+ }
107167
107196
  function createAddOutput() {
107168
107197
  let outputs;
107169
107198
  return { addOutput, getOutputs };
@@ -113639,6 +113668,15 @@ function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host,
113639
113668
  return { impliedNodeFormat, packageJsonLocations, packageJsonScope };
113640
113669
  }
113641
113670
  }
113671
+ function moduleFormatNeedsPackageJsonLookup(fileName, options) {
113672
+ switch (getEmitModuleResolutionKind(options)) {
113673
+ case 3 /* Node16 */:
113674
+ case 99 /* NodeNext */:
113675
+ return fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]);
113676
+ default:
113677
+ return false;
113678
+ }
113679
+ }
113642
113680
  var plainJSErrors = /* @__PURE__ */ new Set([
113643
113681
  // binder errors
113644
113682
  Diagnostics.Cannot_redeclare_block_scoped_variable_0.code,
@@ -113759,6 +113797,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
113759
113797
  let files;
113760
113798
  let symlinks;
113761
113799
  let commonSourceDirectory;
113800
+ let assumedCommonSourceDirectory;
113762
113801
  let typeChecker;
113763
113802
  let classifiableNames;
113764
113803
  const ambientModuleNameToUnmodifiedFileName = /* @__PURE__ */ new Map();
@@ -114250,6 +114289,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
114250
114289
  }
114251
114290
  return commonSourceDirectory;
114252
114291
  }
114292
+ function getAssumedCommonSourceDirectory() {
114293
+ return commonSourceDirectory ?? (assumedCommonSourceDirectory ?? (assumedCommonSourceDirectory = getCommonSourceDirectory(options, () => rootNames, host.getCurrentDirectory(), getCanonicalFileName)));
114294
+ }
114253
114295
  function getClassifiableNames() {
114254
114296
  var _a2;
114255
114297
  if (!classifiableNames) {
@@ -114473,7 +114515,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
114473
114515
  })(SeenPackageName || (SeenPackageName = {}));
114474
114516
  const seenPackageNames = /* @__PURE__ */ new Map();
114475
114517
  for (const oldSourceFile of oldSourceFiles) {
114476
- const sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options);
114518
+ const sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName);
114477
114519
  let newSourceFile = host.getSourceFileByPath ? host.getSourceFileByPath(
114478
114520
  oldSourceFile.fileName,
114479
114521
  oldSourceFile.resolvedPath,
@@ -115435,10 +115477,48 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
115435
115477
  (_b2 = tracing) == null ? void 0 : _b2.pop();
115436
115478
  return result;
115437
115479
  }
115438
- function getCreateSourceFileOptions(fileName, moduleResolutionCache2, host2, options2) {
115439
- const result = getImpliedNodeFormatForFileWorker(getNormalizedAbsolutePath(fileName, currentDirectory), moduleResolutionCache2 == null ? void 0 : moduleResolutionCache2.getPackageJsonInfoCache(), host2, options2);
115440
- const languageVersion = getEmitScriptTarget(options2);
115441
- const setExternalModuleIndicator2 = getSetExternalModuleIndicator(options2);
115480
+ function getImpliedNodeFormatForFile(fileName) {
115481
+ let fileNameForModuleFormatDetection = getNormalizedAbsolutePath(fileName, currentDirectory);
115482
+ if (moduleFormatNeedsPackageJsonLookup(fileName, options)) {
115483
+ const projectReference = getResolvedProjectReferenceToRedirect(fileName);
115484
+ if (projectReference) {
115485
+ Debug.assert(useSourceOfProjectReferenceRedirect);
115486
+ fileNameForModuleFormatDetection = getOutputDeclarationFileName(
115487
+ fileNameForModuleFormatDetection,
115488
+ projectReference.commandLine,
115489
+ !host.useCaseSensitiveFileNames()
115490
+ ) || getOutputJSFileName(
115491
+ fileNameForModuleFormatDetection,
115492
+ projectReference.commandLine,
115493
+ !host.useCaseSensitiveFileNames()
115494
+ ) || fileNameForModuleFormatDetection;
115495
+ } else {
115496
+ fileNameForModuleFormatDetection = getOutputDeclarationFileNameWithoutConfigFile(
115497
+ fileNameForModuleFormatDetection,
115498
+ options,
115499
+ !host.useCaseSensitiveFileNames(),
115500
+ currentDirectory,
115501
+ getAssumedCommonSourceDirectory
115502
+ ) || getOutputJSFileNameWithoutConfigFile(
115503
+ fileNameForModuleFormatDetection,
115504
+ options,
115505
+ !host.useCaseSensitiveFileNames(),
115506
+ currentDirectory,
115507
+ getAssumedCommonSourceDirectory
115508
+ ) || fileNameForModuleFormatDetection;
115509
+ }
115510
+ }
115511
+ return getImpliedNodeFormatForFileWorker(
115512
+ fileNameForModuleFormatDetection,
115513
+ moduleResolutionCache == null ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(),
115514
+ host,
115515
+ options
115516
+ );
115517
+ }
115518
+ function getCreateSourceFileOptions(fileName) {
115519
+ const result = getImpliedNodeFormatForFile(fileName);
115520
+ const languageVersion = getEmitScriptTarget(options);
115521
+ const setExternalModuleIndicator2 = getSetExternalModuleIndicator(options);
115442
115522
  return typeof result === "object" ? { ...result, languageVersion, setExternalModuleIndicator: setExternalModuleIndicator2 } : { languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator2 };
115443
115523
  }
115444
115524
  function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
@@ -115510,7 +115590,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
115510
115590
  redirectedPath = toPath3(redirect);
115511
115591
  }
115512
115592
  }
115513
- const sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options);
115593
+ const sourceFileOptions = getCreateSourceFileOptions(fileName);
115514
115594
  const file = host.getSourceFile(
115515
115595
  fileName,
115516
115596
  sourceFileOptions,
@@ -116133,6 +116213,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
116133
116213
  createDiagnosticForOptionName(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir");
116134
116214
  }
116135
116215
  }
116216
+ if (assumedCommonSourceDirectory && assumedCommonSourceDirectory !== getCommonSourceDirectory2()) {
116217
+ programDiagnostics.add(createCompilerDiagnostic(Diagnostics.The_project_root_is_ambiguous_but_is_required_to_determine_the_module_format_of_output_js_files_Supply_the_rootDir_compiler_option_to_disambiguate));
116218
+ }
116136
116219
  if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) {
116137
116220
  createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields");
116138
116221
  }