@typescript-deploys/pr-build 5.2.0-pr-54536-13 → 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
@@ -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."),
@@ -52656,13 +52657,19 @@ function createTypeChecker(host) {
52656
52657
  if (getObjectFlags(type) & 4 /* Reference */) {
52657
52658
  const target = type.target;
52658
52659
  const typeArguments = getTypeArguments(type);
52659
- return length(target.typeParameters) === length(typeArguments) ? createTypeReference(target, concatenate(typeArguments, [thisArgument || target.thisType])) : type;
52660
+ if (length(target.typeParameters) === length(typeArguments)) {
52661
+ const ref = createTypeReference(target, concatenate(typeArguments, [thisArgument || target.thisType]));
52662
+ return needApparentType ? getApparentType(ref) : ref;
52663
+ }
52660
52664
  } else if (type.flags & 2097152 /* Intersection */) {
52661
52665
  const types = sameMap(type.types, (t) => getTypeWithThisArgument(t, thisArgument, needApparentType));
52662
52666
  return types !== type.types ? getIntersectionType(types) : type;
52663
52667
  }
52664
52668
  return needApparentType ? getApparentType(type) : type;
52665
52669
  }
52670
+ function getThisArgument(type) {
52671
+ return getObjectFlags(type) & 4 /* Reference */ && length(getTypeArguments(type)) > getTypeReferenceArity(type) ? last(getTypeArguments(type)) : type;
52672
+ }
52666
52673
  function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) {
52667
52674
  let mapper;
52668
52675
  let members;
@@ -53728,7 +53735,7 @@ function createTypeChecker(host) {
53728
53735
  return type.resolvedBaseConstraint;
53729
53736
  }
53730
53737
  const stack = [];
53731
- return type.resolvedBaseConstraint = getImmediateBaseConstraint(type);
53738
+ return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), getThisArgument(type));
53732
53739
  function getImmediateBaseConstraint(t) {
53733
53740
  if (!t.immediateBaseConstraint) {
53734
53741
  if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) {
@@ -53820,18 +53827,18 @@ function createTypeChecker(host) {
53820
53827
  }
53821
53828
  if (isGenericTupleType(t)) {
53822
53829
  const newElements = map(getElementTypes(t), (v, i) => {
53823
- const constraint = v.flags & 262144 /* TypeParameter */ && t.target.elementFlags[i] & 8 /* Variadic */ && getBaseConstraint(v) || v;
53824
- return constraint !== v && everyType(constraint, (c) => isArrayOrTupleType(c) && !isGenericTupleType(c)) ? constraint : v;
53830
+ const constraint = t.target.elementFlags[i] & 8 /* Variadic */ && getBaseConstraint(v) || v;
53831
+ return constraint && everyType(constraint, (c) => isArrayOrTupleType(c) && !isGenericTupleType(c)) ? constraint : v;
53825
53832
  });
53826
53833
  return createTupleType(newElements, t.target.elementFlags, t.target.readonly, t.target.labeledElementDeclarations);
53827
53834
  }
53828
53835
  return t;
53829
53836
  }
53830
53837
  }
53831
- function getApparentTypeOfIntersectionType(type, thisArgument) {
53838
+ function getApparentTypeOfIntersectionType(type) {
53832
53839
  return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(
53833
53840
  type,
53834
- thisArgument,
53841
+ type,
53835
53842
  /*needApparentType*/
53836
53843
  true
53837
53844
  ));
@@ -53882,9 +53889,8 @@ function createTypeChecker(host) {
53882
53889
  return !!(type.flags & 8388608 /* IndexedAccess */ && getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType);
53883
53890
  }
53884
53891
  function getApparentType(type) {
53885
- const t = type.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType : type;
53886
- const objectFlags = getObjectFlags(t);
53887
- return objectFlags & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : objectFlags & 4 /* Reference */ && t !== type ? getTypeWithThisArgument(t, type) : t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t, type) : t.flags & 402653316 /* StringLike */ ? globalStringType : t.flags & 296 /* NumberLike */ ? globalNumberType : t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType() : t.flags & 528 /* BooleanLike */ ? globalBooleanType : t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType() : t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : t.flags & 4194304 /* Index */ ? keyofConstraintType : t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : t;
53892
+ const t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType;
53893
+ return getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : t.flags & 402653316 /* StringLike */ ? globalStringType : t.flags & 296 /* NumberLike */ ? globalNumberType : t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType() : t.flags & 528 /* BooleanLike */ ? globalBooleanType : t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType() : t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : t.flags & 4194304 /* Index */ ? keyofConstraintType : t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : t;
53888
53894
  }
53889
53895
  function getReducedApparentType(type) {
53890
53896
  return getReducedType(getApparentType(getReducedType(type)));
@@ -58092,7 +58098,10 @@ function createTypeChecker(host) {
58092
58098
  const newMapper = createTypeMapper(typeParameters, typeArguments);
58093
58099
  result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
58094
58100
  if (result.flags & 138117121 /* ObjectFlagsType */ && !(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
58095
- result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (some(typeArguments, couldContainTypeVariables) ? 1048576 /* CouldContainTypeVariables */ : 0);
58101
+ const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
58102
+ if (!(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
58103
+ result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (resultCouldContainTypeVariables ? 1048576 /* CouldContainTypeVariables */ : 0);
58104
+ }
58096
58105
  }
58097
58106
  target.instantiations.set(id, result);
58098
58107
  }
@@ -60705,7 +60714,7 @@ function createTypeChecker(host) {
60705
60714
  return 3 /* Maybe */;
60706
60715
  }
60707
60716
  const c = target2;
60708
- if (!c.root.inferTypeParameters && !isDistributionDependent(c.root) && !(source2.flags & 16777216 /* Conditional */ && source2.root === c.root)) {
60717
+ if (!c.root.inferTypeParameters && !isDistributionDependent(c.root)) {
60709
60718
  const skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType));
60710
60719
  const skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType));
60711
60720
  if (result2 = skipTrue ? -1 /* True */ : isRelatedTo(
@@ -107153,6 +107162,15 @@ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, get
107153
107162
  getDeclarationEmitExtensionForPath(inputFileName)
107154
107163
  );
107155
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
+ }
107156
107174
  function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory2) {
107157
107175
  if (configFile.options.emitDeclarationOnly)
107158
107176
  return void 0;
@@ -107163,6 +107181,18 @@ function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSou
107163
107181
  );
107164
107182
  return !isJsonFile || comparePaths(inputFileName, outputFileName, Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? outputFileName : void 0;
107165
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
+ }
107166
107196
  function createAddOutput() {
107167
107197
  let outputs;
107168
107198
  return { addOutput, getOutputs };
@@ -113638,6 +113668,15 @@ function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host,
113638
113668
  return { impliedNodeFormat, packageJsonLocations, packageJsonScope };
113639
113669
  }
113640
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
+ }
113641
113680
  var plainJSErrors = /* @__PURE__ */ new Set([
113642
113681
  // binder errors
113643
113682
  Diagnostics.Cannot_redeclare_block_scoped_variable_0.code,
@@ -113758,6 +113797,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
113758
113797
  let files;
113759
113798
  let symlinks;
113760
113799
  let commonSourceDirectory;
113800
+ let assumedCommonSourceDirectory;
113761
113801
  let typeChecker;
113762
113802
  let classifiableNames;
113763
113803
  const ambientModuleNameToUnmodifiedFileName = /* @__PURE__ */ new Map();
@@ -114249,6 +114289,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
114249
114289
  }
114250
114290
  return commonSourceDirectory;
114251
114291
  }
114292
+ function getAssumedCommonSourceDirectory() {
114293
+ return commonSourceDirectory ?? (assumedCommonSourceDirectory ?? (assumedCommonSourceDirectory = getCommonSourceDirectory(options, () => rootNames, host.getCurrentDirectory(), getCanonicalFileName)));
114294
+ }
114252
114295
  function getClassifiableNames() {
114253
114296
  var _a2;
114254
114297
  if (!classifiableNames) {
@@ -114472,7 +114515,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
114472
114515
  })(SeenPackageName || (SeenPackageName = {}));
114473
114516
  const seenPackageNames = /* @__PURE__ */ new Map();
114474
114517
  for (const oldSourceFile of oldSourceFiles) {
114475
- const sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options);
114518
+ const sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName);
114476
114519
  let newSourceFile = host.getSourceFileByPath ? host.getSourceFileByPath(
114477
114520
  oldSourceFile.fileName,
114478
114521
  oldSourceFile.resolvedPath,
@@ -115434,10 +115477,48 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
115434
115477
  (_b2 = tracing) == null ? void 0 : _b2.pop();
115435
115478
  return result;
115436
115479
  }
115437
- function getCreateSourceFileOptions(fileName, moduleResolutionCache2, host2, options2) {
115438
- const result = getImpliedNodeFormatForFileWorker(getNormalizedAbsolutePath(fileName, currentDirectory), moduleResolutionCache2 == null ? void 0 : moduleResolutionCache2.getPackageJsonInfoCache(), host2, options2);
115439
- const languageVersion = getEmitScriptTarget(options2);
115440
- 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);
115441
115522
  return typeof result === "object" ? { ...result, languageVersion, setExternalModuleIndicator: setExternalModuleIndicator2 } : { languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator2 };
115442
115523
  }
115443
115524
  function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
@@ -115509,7 +115590,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
115509
115590
  redirectedPath = toPath3(redirect);
115510
115591
  }
115511
115592
  }
115512
- const sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options);
115593
+ const sourceFileOptions = getCreateSourceFileOptions(fileName);
115513
115594
  const file = host.getSourceFile(
115514
115595
  fileName,
115515
115596
  sourceFileOptions,
@@ -116132,6 +116213,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
116132
116213
  createDiagnosticForOptionName(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir");
116133
116214
  }
116134
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
+ }
116135
116219
  if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) {
116136
116220
  createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields");
116137
116221
  }
package/lib/tsserver.js CHANGED
@@ -919,8 +919,11 @@ __export(server_exports, {
919
919
  getOriginalNodeId: () => getOriginalNodeId,
920
920
  getOriginalSourceFile: () => getOriginalSourceFile,
921
921
  getOutputDeclarationFileName: () => getOutputDeclarationFileName,
922
+ getOutputDeclarationFileNameWithoutConfigFile: () => getOutputDeclarationFileNameWithoutConfigFile,
922
923
  getOutputExtension: () => getOutputExtension,
923
924
  getOutputFileNames: () => getOutputFileNames,
925
+ getOutputJSFileName: () => getOutputJSFileName,
926
+ getOutputJSFileNameWithoutConfigFile: () => getOutputJSFileNameWithoutConfigFile,
924
927
  getOutputPathsFor: () => getOutputPathsFor,
925
928
  getOutputPathsForBundle: () => getOutputPathsForBundle,
926
929
  getOwnEmitOutputFilePath: () => getOwnEmitOutputFilePath,
@@ -9646,6 +9649,7 @@ var Diagnostics = {
9646
9649
  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."),
9647
9650
  Add_extends_constraint: diag(2211, 3 /* Message */, "Add_extends_constraint_2211", "Add `extends` constraint."),
9648
9651
  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"),
9652
+ 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."),
9649
9653
  Duplicate_identifier_0: diag(2300, 1 /* Error */, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
9650
9654
  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."),
9651
9655
  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."),
@@ -57307,13 +57311,19 @@ function createTypeChecker(host) {
57307
57311
  if (getObjectFlags(type) & 4 /* Reference */) {
57308
57312
  const target = type.target;
57309
57313
  const typeArguments = getTypeArguments(type);
57310
- return length(target.typeParameters) === length(typeArguments) ? createTypeReference(target, concatenate(typeArguments, [thisArgument || target.thisType])) : type;
57314
+ if (length(target.typeParameters) === length(typeArguments)) {
57315
+ const ref = createTypeReference(target, concatenate(typeArguments, [thisArgument || target.thisType]));
57316
+ return needApparentType ? getApparentType(ref) : ref;
57317
+ }
57311
57318
  } else if (type.flags & 2097152 /* Intersection */) {
57312
57319
  const types = sameMap(type.types, (t) => getTypeWithThisArgument(t, thisArgument, needApparentType));
57313
57320
  return types !== type.types ? getIntersectionType(types) : type;
57314
57321
  }
57315
57322
  return needApparentType ? getApparentType(type) : type;
57316
57323
  }
57324
+ function getThisArgument(type) {
57325
+ return getObjectFlags(type) & 4 /* Reference */ && length(getTypeArguments(type)) > getTypeReferenceArity(type) ? last(getTypeArguments(type)) : type;
57326
+ }
57317
57327
  function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) {
57318
57328
  let mapper;
57319
57329
  let members;
@@ -58379,7 +58389,7 @@ function createTypeChecker(host) {
58379
58389
  return type.resolvedBaseConstraint;
58380
58390
  }
58381
58391
  const stack = [];
58382
- return type.resolvedBaseConstraint = getImmediateBaseConstraint(type);
58392
+ return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), getThisArgument(type));
58383
58393
  function getImmediateBaseConstraint(t) {
58384
58394
  if (!t.immediateBaseConstraint) {
58385
58395
  if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) {
@@ -58471,18 +58481,18 @@ function createTypeChecker(host) {
58471
58481
  }
58472
58482
  if (isGenericTupleType(t)) {
58473
58483
  const newElements = map(getElementTypes(t), (v, i) => {
58474
- const constraint = v.flags & 262144 /* TypeParameter */ && t.target.elementFlags[i] & 8 /* Variadic */ && getBaseConstraint(v) || v;
58475
- return constraint !== v && everyType(constraint, (c) => isArrayOrTupleType(c) && !isGenericTupleType(c)) ? constraint : v;
58484
+ const constraint = t.target.elementFlags[i] & 8 /* Variadic */ && getBaseConstraint(v) || v;
58485
+ return constraint && everyType(constraint, (c) => isArrayOrTupleType(c) && !isGenericTupleType(c)) ? constraint : v;
58476
58486
  });
58477
58487
  return createTupleType(newElements, t.target.elementFlags, t.target.readonly, t.target.labeledElementDeclarations);
58478
58488
  }
58479
58489
  return t;
58480
58490
  }
58481
58491
  }
58482
- function getApparentTypeOfIntersectionType(type, thisArgument) {
58492
+ function getApparentTypeOfIntersectionType(type) {
58483
58493
  return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(
58484
58494
  type,
58485
- thisArgument,
58495
+ type,
58486
58496
  /*needApparentType*/
58487
58497
  true
58488
58498
  ));
@@ -58533,9 +58543,8 @@ function createTypeChecker(host) {
58533
58543
  return !!(type.flags & 8388608 /* IndexedAccess */ && getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType);
58534
58544
  }
58535
58545
  function getApparentType(type) {
58536
- const t = type.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType : type;
58537
- const objectFlags = getObjectFlags(t);
58538
- return objectFlags & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : objectFlags & 4 /* Reference */ && t !== type ? getTypeWithThisArgument(t, type) : t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t, type) : t.flags & 402653316 /* StringLike */ ? globalStringType : t.flags & 296 /* NumberLike */ ? globalNumberType : t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType() : t.flags & 528 /* BooleanLike */ ? globalBooleanType : t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType() : t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : t.flags & 4194304 /* Index */ ? keyofConstraintType : t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : t;
58546
+ const t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType;
58547
+ return getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : t.flags & 402653316 /* StringLike */ ? globalStringType : t.flags & 296 /* NumberLike */ ? globalNumberType : t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType() : t.flags & 528 /* BooleanLike */ ? globalBooleanType : t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType() : t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : t.flags & 4194304 /* Index */ ? keyofConstraintType : t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : t;
58539
58548
  }
58540
58549
  function getReducedApparentType(type) {
58541
58550
  return getReducedType(getApparentType(getReducedType(type)));
@@ -62743,7 +62752,10 @@ function createTypeChecker(host) {
62743
62752
  const newMapper = createTypeMapper(typeParameters, typeArguments);
62744
62753
  result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
62745
62754
  if (result.flags & 138117121 /* ObjectFlagsType */ && !(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
62746
- result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (some(typeArguments, couldContainTypeVariables) ? 1048576 /* CouldContainTypeVariables */ : 0);
62755
+ const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
62756
+ if (!(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
62757
+ result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (resultCouldContainTypeVariables ? 1048576 /* CouldContainTypeVariables */ : 0);
62758
+ }
62747
62759
  }
62748
62760
  target.instantiations.set(id, result);
62749
62761
  }
@@ -65356,7 +65368,7 @@ function createTypeChecker(host) {
65356
65368
  return 3 /* Maybe */;
65357
65369
  }
65358
65370
  const c = target2;
65359
- if (!c.root.inferTypeParameters && !isDistributionDependent(c.root) && !(source2.flags & 16777216 /* Conditional */ && source2.root === c.root)) {
65371
+ if (!c.root.inferTypeParameters && !isDistributionDependent(c.root)) {
65360
65372
  const skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType));
65361
65373
  const skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType));
65362
65374
  if (result2 = skipTrue ? -1 /* True */ : isRelatedTo(
@@ -111975,6 +111987,15 @@ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, get
111975
111987
  getDeclarationEmitExtensionForPath(inputFileName)
111976
111988
  );
111977
111989
  }
111990
+ function getOutputDeclarationFileNameWithoutConfigFile(inputFileName, options, ignoreCase, currentDirectory, getCommonSourceDirectory2) {
111991
+ const directory = options.declarationDir || options.outDir ? getNormalizedAbsolutePath(options.declarationDir || options.outDir, currentDirectory) : void 0;
111992
+ const outputPathWithoutChangedExtension = directory ? resolvePath(directory, getRelativePathFromDirectory(getCommonSourceDirectory2(), inputFileName, ignoreCase)) : inputFileName;
111993
+ const outputFileName = changeExtension(
111994
+ outputPathWithoutChangedExtension,
111995
+ getDeclarationEmitExtensionForPath(inputFileName)
111996
+ );
111997
+ return outputFileName;
111998
+ }
111978
111999
  function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory2) {
111979
112000
  if (configFile.options.emitDeclarationOnly)
111980
112001
  return void 0;
@@ -111985,6 +112006,18 @@ function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSou
111985
112006
  );
111986
112007
  return !isJsonFile || comparePaths(inputFileName, outputFileName, Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? outputFileName : void 0;
111987
112008
  }
112009
+ function getOutputJSFileNameWithoutConfigFile(inputFileName, options, ignoreCase, currentDirectory, getCommonSourceDirectory2) {
112010
+ if (options.emitDeclarationOnly)
112011
+ return void 0;
112012
+ const isJsonFile = fileExtensionIs(inputFileName, ".json" /* Json */);
112013
+ const outDir = options.outDir ? getNormalizedAbsolutePath(options.outDir, currentDirectory) : void 0;
112014
+ const outputPathWithoutChangedExtension = outDir ? resolvePath(outDir, getRelativePathFromDirectory(getCommonSourceDirectory2(), inputFileName, ignoreCase)) : inputFileName;
112015
+ const outputFileName = changeExtension(
112016
+ outputPathWithoutChangedExtension,
112017
+ getOutputExtension(inputFileName, options)
112018
+ );
112019
+ return !isJsonFile || !options.configFilePath || comparePaths(inputFileName, outputFileName, options.configFilePath, ignoreCase) !== 0 /* EqualTo */ ? outputFileName : void 0;
112020
+ }
111988
112021
  function createAddOutput() {
111989
112022
  let outputs;
111990
112023
  return { addOutput, getOutputs };
@@ -118525,6 +118558,15 @@ function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host,
118525
118558
  return { impliedNodeFormat, packageJsonLocations, packageJsonScope };
118526
118559
  }
118527
118560
  }
118561
+ function moduleFormatNeedsPackageJsonLookup(fileName, options) {
118562
+ switch (getEmitModuleResolutionKind(options)) {
118563
+ case 3 /* Node16 */:
118564
+ case 99 /* NodeNext */:
118565
+ return fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]);
118566
+ default:
118567
+ return false;
118568
+ }
118569
+ }
118528
118570
  var plainJSErrors = /* @__PURE__ */ new Set([
118529
118571
  // binder errors
118530
118572
  Diagnostics.Cannot_redeclare_block_scoped_variable_0.code,
@@ -118645,6 +118687,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118645
118687
  let files;
118646
118688
  let symlinks;
118647
118689
  let commonSourceDirectory;
118690
+ let assumedCommonSourceDirectory;
118648
118691
  let typeChecker;
118649
118692
  let classifiableNames;
118650
118693
  const ambientModuleNameToUnmodifiedFileName = /* @__PURE__ */ new Map();
@@ -119136,6 +119179,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119136
119179
  }
119137
119180
  return commonSourceDirectory;
119138
119181
  }
119182
+ function getAssumedCommonSourceDirectory() {
119183
+ return commonSourceDirectory ?? (assumedCommonSourceDirectory ?? (assumedCommonSourceDirectory = getCommonSourceDirectory(options, () => rootNames, host.getCurrentDirectory(), getCanonicalFileName)));
119184
+ }
119139
119185
  function getClassifiableNames() {
119140
119186
  var _a2;
119141
119187
  if (!classifiableNames) {
@@ -119359,7 +119405,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119359
119405
  })(SeenPackageName || (SeenPackageName = {}));
119360
119406
  const seenPackageNames = /* @__PURE__ */ new Map();
119361
119407
  for (const oldSourceFile of oldSourceFiles) {
119362
- const sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options);
119408
+ const sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName);
119363
119409
  let newSourceFile = host.getSourceFileByPath ? host.getSourceFileByPath(
119364
119410
  oldSourceFile.fileName,
119365
119411
  oldSourceFile.resolvedPath,
@@ -120321,10 +120367,48 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120321
120367
  (_b2 = tracing) == null ? void 0 : _b2.pop();
120322
120368
  return result;
120323
120369
  }
120324
- function getCreateSourceFileOptions(fileName, moduleResolutionCache2, host2, options2) {
120325
- const result = getImpliedNodeFormatForFileWorker(getNormalizedAbsolutePath(fileName, currentDirectory), moduleResolutionCache2 == null ? void 0 : moduleResolutionCache2.getPackageJsonInfoCache(), host2, options2);
120326
- const languageVersion = getEmitScriptTarget(options2);
120327
- const setExternalModuleIndicator2 = getSetExternalModuleIndicator(options2);
120370
+ function getImpliedNodeFormatForFile2(fileName) {
120371
+ let fileNameForModuleFormatDetection = getNormalizedAbsolutePath(fileName, currentDirectory);
120372
+ if (moduleFormatNeedsPackageJsonLookup(fileName, options)) {
120373
+ const projectReference = getResolvedProjectReferenceToRedirect(fileName);
120374
+ if (projectReference) {
120375
+ Debug.assert(useSourceOfProjectReferenceRedirect);
120376
+ fileNameForModuleFormatDetection = getOutputDeclarationFileName(
120377
+ fileNameForModuleFormatDetection,
120378
+ projectReference.commandLine,
120379
+ !host.useCaseSensitiveFileNames()
120380
+ ) || getOutputJSFileName(
120381
+ fileNameForModuleFormatDetection,
120382
+ projectReference.commandLine,
120383
+ !host.useCaseSensitiveFileNames()
120384
+ ) || fileNameForModuleFormatDetection;
120385
+ } else {
120386
+ fileNameForModuleFormatDetection = getOutputDeclarationFileNameWithoutConfigFile(
120387
+ fileNameForModuleFormatDetection,
120388
+ options,
120389
+ !host.useCaseSensitiveFileNames(),
120390
+ currentDirectory,
120391
+ getAssumedCommonSourceDirectory
120392
+ ) || getOutputJSFileNameWithoutConfigFile(
120393
+ fileNameForModuleFormatDetection,
120394
+ options,
120395
+ !host.useCaseSensitiveFileNames(),
120396
+ currentDirectory,
120397
+ getAssumedCommonSourceDirectory
120398
+ ) || fileNameForModuleFormatDetection;
120399
+ }
120400
+ }
120401
+ return getImpliedNodeFormatForFileWorker(
120402
+ fileNameForModuleFormatDetection,
120403
+ moduleResolutionCache == null ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(),
120404
+ host,
120405
+ options
120406
+ );
120407
+ }
120408
+ function getCreateSourceFileOptions(fileName) {
120409
+ const result = getImpliedNodeFormatForFile2(fileName);
120410
+ const languageVersion = getEmitScriptTarget(options);
120411
+ const setExternalModuleIndicator2 = getSetExternalModuleIndicator(options);
120328
120412
  return typeof result === "object" ? { ...result, languageVersion, setExternalModuleIndicator: setExternalModuleIndicator2 } : { languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator2 };
120329
120413
  }
120330
120414
  function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
@@ -120396,7 +120480,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120396
120480
  redirectedPath = toPath3(redirect);
120397
120481
  }
120398
120482
  }
120399
- const sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options);
120483
+ const sourceFileOptions = getCreateSourceFileOptions(fileName);
120400
120484
  const file = host.getSourceFile(
120401
120485
  fileName,
120402
120486
  sourceFileOptions,
@@ -121019,6 +121103,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121019
121103
  createDiagnosticForOptionName(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir");
121020
121104
  }
121021
121105
  }
121106
+ if (assumedCommonSourceDirectory && assumedCommonSourceDirectory !== getCommonSourceDirectory2()) {
121107
+ 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));
121108
+ }
121022
121109
  if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) {
121023
121110
  createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields");
121024
121111
  }
@@ -170799,8 +170886,11 @@ __export(ts_exports2, {
170799
170886
  getOriginalNodeId: () => getOriginalNodeId,
170800
170887
  getOriginalSourceFile: () => getOriginalSourceFile,
170801
170888
  getOutputDeclarationFileName: () => getOutputDeclarationFileName,
170889
+ getOutputDeclarationFileNameWithoutConfigFile: () => getOutputDeclarationFileNameWithoutConfigFile,
170802
170890
  getOutputExtension: () => getOutputExtension,
170803
170891
  getOutputFileNames: () => getOutputFileNames,
170892
+ getOutputJSFileName: () => getOutputJSFileName,
170893
+ getOutputJSFileNameWithoutConfigFile: () => getOutputJSFileNameWithoutConfigFile,
170804
170894
  getOutputPathsFor: () => getOutputPathsFor,
170805
170895
  getOutputPathsForBundle: () => getOutputPathsForBundle,
170806
170896
  getOwnEmitOutputFilePath: () => getOwnEmitOutputFilePath,
@@ -185272,8 +185362,11 @@ start(initializeNodeSystem(), require("os").platform());
185272
185362
  getOriginalNodeId,
185273
185363
  getOriginalSourceFile,
185274
185364
  getOutputDeclarationFileName,
185365
+ getOutputDeclarationFileNameWithoutConfigFile,
185275
185366
  getOutputExtension,
185276
185367
  getOutputFileNames,
185368
+ getOutputJSFileName,
185369
+ getOutputJSFileNameWithoutConfigFile,
185277
185370
  getOutputPathsFor,
185278
185371
  getOutputPathsForBundle,
185279
185372
  getOwnEmitOutputFilePath,
@@ -7452,6 +7452,7 @@ ${lanes.join("\n")}
7452
7452
  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."),
7453
7453
  Add_extends_constraint: diag(2211, 3 /* Message */, "Add_extends_constraint_2211", "Add `extends` constraint."),
7454
7454
  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"),
7455
+ 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."),
7455
7456
  Duplicate_identifier_0: diag(2300, 1 /* Error */, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
7456
7457
  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."),
7457
7458
  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."),
@@ -55096,13 +55097,19 @@ ${lanes.join("\n")}
55096
55097
  if (getObjectFlags(type) & 4 /* Reference */) {
55097
55098
  const target = type.target;
55098
55099
  const typeArguments = getTypeArguments(type);
55099
- return length(target.typeParameters) === length(typeArguments) ? createTypeReference(target, concatenate(typeArguments, [thisArgument || target.thisType])) : type;
55100
+ if (length(target.typeParameters) === length(typeArguments)) {
55101
+ const ref = createTypeReference(target, concatenate(typeArguments, [thisArgument || target.thisType]));
55102
+ return needApparentType ? getApparentType(ref) : ref;
55103
+ }
55100
55104
  } else if (type.flags & 2097152 /* Intersection */) {
55101
55105
  const types = sameMap(type.types, (t) => getTypeWithThisArgument(t, thisArgument, needApparentType));
55102
55106
  return types !== type.types ? getIntersectionType(types) : type;
55103
55107
  }
55104
55108
  return needApparentType ? getApparentType(type) : type;
55105
55109
  }
55110
+ function getThisArgument(type) {
55111
+ return getObjectFlags(type) & 4 /* Reference */ && length(getTypeArguments(type)) > getTypeReferenceArity(type) ? last(getTypeArguments(type)) : type;
55112
+ }
55106
55113
  function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) {
55107
55114
  let mapper;
55108
55115
  let members;
@@ -56168,7 +56175,7 @@ ${lanes.join("\n")}
56168
56175
  return type.resolvedBaseConstraint;
56169
56176
  }
56170
56177
  const stack = [];
56171
- return type.resolvedBaseConstraint = getImmediateBaseConstraint(type);
56178
+ return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), getThisArgument(type));
56172
56179
  function getImmediateBaseConstraint(t) {
56173
56180
  if (!t.immediateBaseConstraint) {
56174
56181
  if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) {
@@ -56260,18 +56267,18 @@ ${lanes.join("\n")}
56260
56267
  }
56261
56268
  if (isGenericTupleType(t)) {
56262
56269
  const newElements = map(getElementTypes(t), (v, i) => {
56263
- const constraint = v.flags & 262144 /* TypeParameter */ && t.target.elementFlags[i] & 8 /* Variadic */ && getBaseConstraint(v) || v;
56264
- return constraint !== v && everyType(constraint, (c) => isArrayOrTupleType(c) && !isGenericTupleType(c)) ? constraint : v;
56270
+ const constraint = t.target.elementFlags[i] & 8 /* Variadic */ && getBaseConstraint(v) || v;
56271
+ return constraint && everyType(constraint, (c) => isArrayOrTupleType(c) && !isGenericTupleType(c)) ? constraint : v;
56265
56272
  });
56266
56273
  return createTupleType(newElements, t.target.elementFlags, t.target.readonly, t.target.labeledElementDeclarations);
56267
56274
  }
56268
56275
  return t;
56269
56276
  }
56270
56277
  }
56271
- function getApparentTypeOfIntersectionType(type, thisArgument) {
56278
+ function getApparentTypeOfIntersectionType(type) {
56272
56279
  return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(
56273
56280
  type,
56274
- thisArgument,
56281
+ type,
56275
56282
  /*needApparentType*/
56276
56283
  true
56277
56284
  ));
@@ -56322,9 +56329,8 @@ ${lanes.join("\n")}
56322
56329
  return !!(type.flags & 8388608 /* IndexedAccess */ && getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType);
56323
56330
  }
56324
56331
  function getApparentType(type) {
56325
- const t = type.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType : type;
56326
- const objectFlags = getObjectFlags(t);
56327
- return objectFlags & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : objectFlags & 4 /* Reference */ && t !== type ? getTypeWithThisArgument(t, type) : t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t, type) : t.flags & 402653316 /* StringLike */ ? globalStringType : t.flags & 296 /* NumberLike */ ? globalNumberType : t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType() : t.flags & 528 /* BooleanLike */ ? globalBooleanType : t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType() : t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : t.flags & 4194304 /* Index */ ? keyofConstraintType : t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : t;
56332
+ const t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType;
56333
+ return getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : t.flags & 402653316 /* StringLike */ ? globalStringType : t.flags & 296 /* NumberLike */ ? globalNumberType : t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType() : t.flags & 528 /* BooleanLike */ ? globalBooleanType : t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType() : t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : t.flags & 4194304 /* Index */ ? keyofConstraintType : t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : t;
56328
56334
  }
56329
56335
  function getReducedApparentType(type) {
56330
56336
  return getReducedType(getApparentType(getReducedType(type)));
@@ -60532,7 +60538,10 @@ ${lanes.join("\n")}
60532
60538
  const newMapper = createTypeMapper(typeParameters, typeArguments);
60533
60539
  result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
60534
60540
  if (result.flags & 138117121 /* ObjectFlagsType */ && !(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
60535
- result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (some(typeArguments, couldContainTypeVariables) ? 1048576 /* CouldContainTypeVariables */ : 0);
60541
+ const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
60542
+ if (!(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
60543
+ result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (resultCouldContainTypeVariables ? 1048576 /* CouldContainTypeVariables */ : 0);
60544
+ }
60536
60545
  }
60537
60546
  target.instantiations.set(id, result);
60538
60547
  }
@@ -63145,7 +63154,7 @@ ${lanes.join("\n")}
63145
63154
  return 3 /* Maybe */;
63146
63155
  }
63147
63156
  const c = target2;
63148
- if (!c.root.inferTypeParameters && !isDistributionDependent(c.root) && !(source2.flags & 16777216 /* Conditional */ && source2.root === c.root)) {
63157
+ if (!c.root.inferTypeParameters && !isDistributionDependent(c.root)) {
63149
63158
  const skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType));
63150
63159
  const skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType));
63151
63160
  if (result2 = skipTrue ? -1 /* True */ : isRelatedTo(
@@ -110078,6 +110087,15 @@ ${lanes.join("\n")}
110078
110087
  getDeclarationEmitExtensionForPath(inputFileName)
110079
110088
  );
110080
110089
  }
110090
+ function getOutputDeclarationFileNameWithoutConfigFile(inputFileName, options, ignoreCase, currentDirectory, getCommonSourceDirectory2) {
110091
+ const directory = options.declarationDir || options.outDir ? getNormalizedAbsolutePath(options.declarationDir || options.outDir, currentDirectory) : void 0;
110092
+ const outputPathWithoutChangedExtension = directory ? resolvePath(directory, getRelativePathFromDirectory(getCommonSourceDirectory2(), inputFileName, ignoreCase)) : inputFileName;
110093
+ const outputFileName = changeExtension(
110094
+ outputPathWithoutChangedExtension,
110095
+ getDeclarationEmitExtensionForPath(inputFileName)
110096
+ );
110097
+ return outputFileName;
110098
+ }
110081
110099
  function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory2) {
110082
110100
  if (configFile.options.emitDeclarationOnly)
110083
110101
  return void 0;
@@ -110088,6 +110106,18 @@ ${lanes.join("\n")}
110088
110106
  );
110089
110107
  return !isJsonFile || comparePaths(inputFileName, outputFileName, Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? outputFileName : void 0;
110090
110108
  }
110109
+ function getOutputJSFileNameWithoutConfigFile(inputFileName, options, ignoreCase, currentDirectory, getCommonSourceDirectory2) {
110110
+ if (options.emitDeclarationOnly)
110111
+ return void 0;
110112
+ const isJsonFile = fileExtensionIs(inputFileName, ".json" /* Json */);
110113
+ const outDir = options.outDir ? getNormalizedAbsolutePath(options.outDir, currentDirectory) : void 0;
110114
+ const outputPathWithoutChangedExtension = outDir ? resolvePath(outDir, getRelativePathFromDirectory(getCommonSourceDirectory2(), inputFileName, ignoreCase)) : inputFileName;
110115
+ const outputFileName = changeExtension(
110116
+ outputPathWithoutChangedExtension,
110117
+ getOutputExtension(inputFileName, options)
110118
+ );
110119
+ return !isJsonFile || !options.configFilePath || comparePaths(inputFileName, outputFileName, options.configFilePath, ignoreCase) !== 0 /* EqualTo */ ? outputFileName : void 0;
110120
+ }
110091
110121
  function createAddOutput() {
110092
110122
  let outputs;
110093
110123
  return { addOutput, getOutputs };
@@ -116618,6 +116648,15 @@ ${lanes.join("\n")}
116618
116648
  return { impliedNodeFormat, packageJsonLocations, packageJsonScope };
116619
116649
  }
116620
116650
  }
116651
+ function moduleFormatNeedsPackageJsonLookup(fileName, options) {
116652
+ switch (getEmitModuleResolutionKind(options)) {
116653
+ case 3 /* Node16 */:
116654
+ case 99 /* NodeNext */:
116655
+ return fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]);
116656
+ default:
116657
+ return false;
116658
+ }
116659
+ }
116621
116660
  function shouldProgramCreateNewSourceFiles(program, newOptions) {
116622
116661
  if (!program)
116623
116662
  return false;
@@ -116644,6 +116683,7 @@ ${lanes.join("\n")}
116644
116683
  let files;
116645
116684
  let symlinks;
116646
116685
  let commonSourceDirectory;
116686
+ let assumedCommonSourceDirectory;
116647
116687
  let typeChecker;
116648
116688
  let classifiableNames;
116649
116689
  const ambientModuleNameToUnmodifiedFileName = /* @__PURE__ */ new Map();
@@ -117135,6 +117175,9 @@ ${lanes.join("\n")}
117135
117175
  }
117136
117176
  return commonSourceDirectory;
117137
117177
  }
117178
+ function getAssumedCommonSourceDirectory() {
117179
+ return commonSourceDirectory ?? (assumedCommonSourceDirectory ?? (assumedCommonSourceDirectory = getCommonSourceDirectory(options, () => rootNames, host.getCurrentDirectory(), getCanonicalFileName)));
117180
+ }
117138
117181
  function getClassifiableNames() {
117139
117182
  var _a2;
117140
117183
  if (!classifiableNames) {
@@ -117358,7 +117401,7 @@ ${lanes.join("\n")}
117358
117401
  })(SeenPackageName || (SeenPackageName = {}));
117359
117402
  const seenPackageNames = /* @__PURE__ */ new Map();
117360
117403
  for (const oldSourceFile of oldSourceFiles) {
117361
- const sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options);
117404
+ const sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName);
117362
117405
  let newSourceFile = host.getSourceFileByPath ? host.getSourceFileByPath(
117363
117406
  oldSourceFile.fileName,
117364
117407
  oldSourceFile.resolvedPath,
@@ -118320,10 +118363,48 @@ ${lanes.join("\n")}
118320
118363
  (_b2 = tracing) == null ? void 0 : _b2.pop();
118321
118364
  return result;
118322
118365
  }
118323
- function getCreateSourceFileOptions(fileName, moduleResolutionCache2, host2, options2) {
118324
- const result = getImpliedNodeFormatForFileWorker(getNormalizedAbsolutePath(fileName, currentDirectory), moduleResolutionCache2 == null ? void 0 : moduleResolutionCache2.getPackageJsonInfoCache(), host2, options2);
118325
- const languageVersion = getEmitScriptTarget(options2);
118326
- const setExternalModuleIndicator2 = getSetExternalModuleIndicator(options2);
118366
+ function getImpliedNodeFormatForFile2(fileName) {
118367
+ let fileNameForModuleFormatDetection = getNormalizedAbsolutePath(fileName, currentDirectory);
118368
+ if (moduleFormatNeedsPackageJsonLookup(fileName, options)) {
118369
+ const projectReference = getResolvedProjectReferenceToRedirect(fileName);
118370
+ if (projectReference) {
118371
+ Debug.assert(useSourceOfProjectReferenceRedirect);
118372
+ fileNameForModuleFormatDetection = getOutputDeclarationFileName(
118373
+ fileNameForModuleFormatDetection,
118374
+ projectReference.commandLine,
118375
+ !host.useCaseSensitiveFileNames()
118376
+ ) || getOutputJSFileName(
118377
+ fileNameForModuleFormatDetection,
118378
+ projectReference.commandLine,
118379
+ !host.useCaseSensitiveFileNames()
118380
+ ) || fileNameForModuleFormatDetection;
118381
+ } else {
118382
+ fileNameForModuleFormatDetection = getOutputDeclarationFileNameWithoutConfigFile(
118383
+ fileNameForModuleFormatDetection,
118384
+ options,
118385
+ !host.useCaseSensitiveFileNames(),
118386
+ currentDirectory,
118387
+ getAssumedCommonSourceDirectory
118388
+ ) || getOutputJSFileNameWithoutConfigFile(
118389
+ fileNameForModuleFormatDetection,
118390
+ options,
118391
+ !host.useCaseSensitiveFileNames(),
118392
+ currentDirectory,
118393
+ getAssumedCommonSourceDirectory
118394
+ ) || fileNameForModuleFormatDetection;
118395
+ }
118396
+ }
118397
+ return getImpliedNodeFormatForFileWorker(
118398
+ fileNameForModuleFormatDetection,
118399
+ moduleResolutionCache == null ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(),
118400
+ host,
118401
+ options
118402
+ );
118403
+ }
118404
+ function getCreateSourceFileOptions(fileName) {
118405
+ const result = getImpliedNodeFormatForFile2(fileName);
118406
+ const languageVersion = getEmitScriptTarget(options);
118407
+ const setExternalModuleIndicator2 = getSetExternalModuleIndicator(options);
118327
118408
  return typeof result === "object" ? { ...result, languageVersion, setExternalModuleIndicator: setExternalModuleIndicator2 } : { languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator2 };
118328
118409
  }
118329
118410
  function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
@@ -118395,7 +118476,7 @@ ${lanes.join("\n")}
118395
118476
  redirectedPath = toPath3(redirect);
118396
118477
  }
118397
118478
  }
118398
- const sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options);
118479
+ const sourceFileOptions = getCreateSourceFileOptions(fileName);
118399
118480
  const file = host.getSourceFile(
118400
118481
  fileName,
118401
118482
  sourceFileOptions,
@@ -119018,6 +119099,9 @@ ${lanes.join("\n")}
119018
119099
  createDiagnosticForOptionName(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir");
119019
119100
  }
119020
119101
  }
119102
+ if (assumedCommonSourceDirectory && assumedCommonSourceDirectory !== getCommonSourceDirectory2()) {
119103
+ 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));
119104
+ }
119021
119105
  if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) {
119022
119106
  createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields");
119023
119107
  }
@@ -181922,8 +182006,11 @@ ${e.message}`;
181922
182006
  getOriginalNodeId: () => getOriginalNodeId,
181923
182007
  getOriginalSourceFile: () => getOriginalSourceFile,
181924
182008
  getOutputDeclarationFileName: () => getOutputDeclarationFileName,
182009
+ getOutputDeclarationFileNameWithoutConfigFile: () => getOutputDeclarationFileNameWithoutConfigFile,
181925
182010
  getOutputExtension: () => getOutputExtension,
181926
182011
  getOutputFileNames: () => getOutputFileNames,
182012
+ getOutputJSFileName: () => getOutputJSFileName,
182013
+ getOutputJSFileNameWithoutConfigFile: () => getOutputJSFileNameWithoutConfigFile,
181927
182014
  getOutputPathsFor: () => getOutputPathsFor,
181928
182015
  getOutputPathsForBundle: () => getOutputPathsForBundle,
181929
182016
  getOwnEmitOutputFilePath: () => getOwnEmitOutputFilePath,
@@ -184301,8 +184388,11 @@ ${e.message}`;
184301
184388
  getOriginalNodeId: () => getOriginalNodeId,
184302
184389
  getOriginalSourceFile: () => getOriginalSourceFile,
184303
184390
  getOutputDeclarationFileName: () => getOutputDeclarationFileName,
184391
+ getOutputDeclarationFileNameWithoutConfigFile: () => getOutputDeclarationFileNameWithoutConfigFile,
184304
184392
  getOutputExtension: () => getOutputExtension,
184305
184393
  getOutputFileNames: () => getOutputFileNames,
184394
+ getOutputJSFileName: () => getOutputJSFileName,
184395
+ getOutputJSFileNameWithoutConfigFile: () => getOutputJSFileNameWithoutConfigFile,
184306
184396
  getOutputPathsFor: () => getOutputPathsFor,
184307
184397
  getOutputPathsForBundle: () => getOutputPathsForBundle,
184308
184398
  getOwnEmitOutputFilePath: () => getOwnEmitOutputFilePath,
package/lib/typescript.js CHANGED
@@ -7452,6 +7452,7 @@ ${lanes.join("\n")}
7452
7452
  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."),
7453
7453
  Add_extends_constraint: diag(2211, 3 /* Message */, "Add_extends_constraint_2211", "Add `extends` constraint."),
7454
7454
  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"),
7455
+ 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."),
7455
7456
  Duplicate_identifier_0: diag(2300, 1 /* Error */, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
7456
7457
  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."),
7457
7458
  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."),
@@ -55096,13 +55097,19 @@ ${lanes.join("\n")}
55096
55097
  if (getObjectFlags(type) & 4 /* Reference */) {
55097
55098
  const target = type.target;
55098
55099
  const typeArguments = getTypeArguments(type);
55099
- return length(target.typeParameters) === length(typeArguments) ? createTypeReference(target, concatenate(typeArguments, [thisArgument || target.thisType])) : type;
55100
+ if (length(target.typeParameters) === length(typeArguments)) {
55101
+ const ref = createTypeReference(target, concatenate(typeArguments, [thisArgument || target.thisType]));
55102
+ return needApparentType ? getApparentType(ref) : ref;
55103
+ }
55100
55104
  } else if (type.flags & 2097152 /* Intersection */) {
55101
55105
  const types = sameMap(type.types, (t) => getTypeWithThisArgument(t, thisArgument, needApparentType));
55102
55106
  return types !== type.types ? getIntersectionType(types) : type;
55103
55107
  }
55104
55108
  return needApparentType ? getApparentType(type) : type;
55105
55109
  }
55110
+ function getThisArgument(type) {
55111
+ return getObjectFlags(type) & 4 /* Reference */ && length(getTypeArguments(type)) > getTypeReferenceArity(type) ? last(getTypeArguments(type)) : type;
55112
+ }
55106
55113
  function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) {
55107
55114
  let mapper;
55108
55115
  let members;
@@ -56168,7 +56175,7 @@ ${lanes.join("\n")}
56168
56175
  return type.resolvedBaseConstraint;
56169
56176
  }
56170
56177
  const stack = [];
56171
- return type.resolvedBaseConstraint = getImmediateBaseConstraint(type);
56178
+ return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), getThisArgument(type));
56172
56179
  function getImmediateBaseConstraint(t) {
56173
56180
  if (!t.immediateBaseConstraint) {
56174
56181
  if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) {
@@ -56260,18 +56267,18 @@ ${lanes.join("\n")}
56260
56267
  }
56261
56268
  if (isGenericTupleType(t)) {
56262
56269
  const newElements = map(getElementTypes(t), (v, i) => {
56263
- const constraint = v.flags & 262144 /* TypeParameter */ && t.target.elementFlags[i] & 8 /* Variadic */ && getBaseConstraint(v) || v;
56264
- return constraint !== v && everyType(constraint, (c) => isArrayOrTupleType(c) && !isGenericTupleType(c)) ? constraint : v;
56270
+ const constraint = t.target.elementFlags[i] & 8 /* Variadic */ && getBaseConstraint(v) || v;
56271
+ return constraint && everyType(constraint, (c) => isArrayOrTupleType(c) && !isGenericTupleType(c)) ? constraint : v;
56265
56272
  });
56266
56273
  return createTupleType(newElements, t.target.elementFlags, t.target.readonly, t.target.labeledElementDeclarations);
56267
56274
  }
56268
56275
  return t;
56269
56276
  }
56270
56277
  }
56271
- function getApparentTypeOfIntersectionType(type, thisArgument) {
56278
+ function getApparentTypeOfIntersectionType(type) {
56272
56279
  return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(
56273
56280
  type,
56274
- thisArgument,
56281
+ type,
56275
56282
  /*needApparentType*/
56276
56283
  true
56277
56284
  ));
@@ -56322,9 +56329,8 @@ ${lanes.join("\n")}
56322
56329
  return !!(type.flags & 8388608 /* IndexedAccess */ && getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType);
56323
56330
  }
56324
56331
  function getApparentType(type) {
56325
- const t = type.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType : type;
56326
- const objectFlags = getObjectFlags(t);
56327
- return objectFlags & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : objectFlags & 4 /* Reference */ && t !== type ? getTypeWithThisArgument(t, type) : t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t, type) : t.flags & 402653316 /* StringLike */ ? globalStringType : t.flags & 296 /* NumberLike */ ? globalNumberType : t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType() : t.flags & 528 /* BooleanLike */ ? globalBooleanType : t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType() : t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : t.flags & 4194304 /* Index */ ? keyofConstraintType : t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : t;
56332
+ const t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType;
56333
+ return getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : t.flags & 402653316 /* StringLike */ ? globalStringType : t.flags & 296 /* NumberLike */ ? globalNumberType : t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType() : t.flags & 528 /* BooleanLike */ ? globalBooleanType : t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType() : t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : t.flags & 4194304 /* Index */ ? keyofConstraintType : t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : t;
56328
56334
  }
56329
56335
  function getReducedApparentType(type) {
56330
56336
  return getReducedType(getApparentType(getReducedType(type)));
@@ -60532,7 +60538,10 @@ ${lanes.join("\n")}
60532
60538
  const newMapper = createTypeMapper(typeParameters, typeArguments);
60533
60539
  result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
60534
60540
  if (result.flags & 138117121 /* ObjectFlagsType */ && !(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
60535
- result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (some(typeArguments, couldContainTypeVariables) ? 1048576 /* CouldContainTypeVariables */ : 0);
60541
+ const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
60542
+ if (!(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
60543
+ result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (resultCouldContainTypeVariables ? 1048576 /* CouldContainTypeVariables */ : 0);
60544
+ }
60536
60545
  }
60537
60546
  target.instantiations.set(id, result);
60538
60547
  }
@@ -63145,7 +63154,7 @@ ${lanes.join("\n")}
63145
63154
  return 3 /* Maybe */;
63146
63155
  }
63147
63156
  const c = target2;
63148
- if (!c.root.inferTypeParameters && !isDistributionDependent(c.root) && !(source2.flags & 16777216 /* Conditional */ && source2.root === c.root)) {
63157
+ if (!c.root.inferTypeParameters && !isDistributionDependent(c.root)) {
63149
63158
  const skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType));
63150
63159
  const skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType));
63151
63160
  if (result2 = skipTrue ? -1 /* True */ : isRelatedTo(
@@ -110078,6 +110087,15 @@ ${lanes.join("\n")}
110078
110087
  getDeclarationEmitExtensionForPath(inputFileName)
110079
110088
  );
110080
110089
  }
110090
+ function getOutputDeclarationFileNameWithoutConfigFile(inputFileName, options, ignoreCase, currentDirectory, getCommonSourceDirectory2) {
110091
+ const directory = options.declarationDir || options.outDir ? getNormalizedAbsolutePath(options.declarationDir || options.outDir, currentDirectory) : void 0;
110092
+ const outputPathWithoutChangedExtension = directory ? resolvePath(directory, getRelativePathFromDirectory(getCommonSourceDirectory2(), inputFileName, ignoreCase)) : inputFileName;
110093
+ const outputFileName = changeExtension(
110094
+ outputPathWithoutChangedExtension,
110095
+ getDeclarationEmitExtensionForPath(inputFileName)
110096
+ );
110097
+ return outputFileName;
110098
+ }
110081
110099
  function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory2) {
110082
110100
  if (configFile.options.emitDeclarationOnly)
110083
110101
  return void 0;
@@ -110088,6 +110106,18 @@ ${lanes.join("\n")}
110088
110106
  );
110089
110107
  return !isJsonFile || comparePaths(inputFileName, outputFileName, Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? outputFileName : void 0;
110090
110108
  }
110109
+ function getOutputJSFileNameWithoutConfigFile(inputFileName, options, ignoreCase, currentDirectory, getCommonSourceDirectory2) {
110110
+ if (options.emitDeclarationOnly)
110111
+ return void 0;
110112
+ const isJsonFile = fileExtensionIs(inputFileName, ".json" /* Json */);
110113
+ const outDir = options.outDir ? getNormalizedAbsolutePath(options.outDir, currentDirectory) : void 0;
110114
+ const outputPathWithoutChangedExtension = outDir ? resolvePath(outDir, getRelativePathFromDirectory(getCommonSourceDirectory2(), inputFileName, ignoreCase)) : inputFileName;
110115
+ const outputFileName = changeExtension(
110116
+ outputPathWithoutChangedExtension,
110117
+ getOutputExtension(inputFileName, options)
110118
+ );
110119
+ return !isJsonFile || !options.configFilePath || comparePaths(inputFileName, outputFileName, options.configFilePath, ignoreCase) !== 0 /* EqualTo */ ? outputFileName : void 0;
110120
+ }
110091
110121
  function createAddOutput() {
110092
110122
  let outputs;
110093
110123
  return { addOutput, getOutputs };
@@ -116618,6 +116648,15 @@ ${lanes.join("\n")}
116618
116648
  return { impliedNodeFormat, packageJsonLocations, packageJsonScope };
116619
116649
  }
116620
116650
  }
116651
+ function moduleFormatNeedsPackageJsonLookup(fileName, options) {
116652
+ switch (getEmitModuleResolutionKind(options)) {
116653
+ case 3 /* Node16 */:
116654
+ case 99 /* NodeNext */:
116655
+ return fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]);
116656
+ default:
116657
+ return false;
116658
+ }
116659
+ }
116621
116660
  function shouldProgramCreateNewSourceFiles(program, newOptions) {
116622
116661
  if (!program)
116623
116662
  return false;
@@ -116644,6 +116683,7 @@ ${lanes.join("\n")}
116644
116683
  let files;
116645
116684
  let symlinks;
116646
116685
  let commonSourceDirectory;
116686
+ let assumedCommonSourceDirectory;
116647
116687
  let typeChecker;
116648
116688
  let classifiableNames;
116649
116689
  const ambientModuleNameToUnmodifiedFileName = /* @__PURE__ */ new Map();
@@ -117135,6 +117175,9 @@ ${lanes.join("\n")}
117135
117175
  }
117136
117176
  return commonSourceDirectory;
117137
117177
  }
117178
+ function getAssumedCommonSourceDirectory() {
117179
+ return commonSourceDirectory ?? (assumedCommonSourceDirectory ?? (assumedCommonSourceDirectory = getCommonSourceDirectory(options, () => rootNames, host.getCurrentDirectory(), getCanonicalFileName)));
117180
+ }
117138
117181
  function getClassifiableNames() {
117139
117182
  var _a2;
117140
117183
  if (!classifiableNames) {
@@ -117358,7 +117401,7 @@ ${lanes.join("\n")}
117358
117401
  })(SeenPackageName || (SeenPackageName = {}));
117359
117402
  const seenPackageNames = /* @__PURE__ */ new Map();
117360
117403
  for (const oldSourceFile of oldSourceFiles) {
117361
- const sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options);
117404
+ const sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName);
117362
117405
  let newSourceFile = host.getSourceFileByPath ? host.getSourceFileByPath(
117363
117406
  oldSourceFile.fileName,
117364
117407
  oldSourceFile.resolvedPath,
@@ -118320,10 +118363,48 @@ ${lanes.join("\n")}
118320
118363
  (_b2 = tracing) == null ? void 0 : _b2.pop();
118321
118364
  return result;
118322
118365
  }
118323
- function getCreateSourceFileOptions(fileName, moduleResolutionCache2, host2, options2) {
118324
- const result = getImpliedNodeFormatForFileWorker(getNormalizedAbsolutePath(fileName, currentDirectory), moduleResolutionCache2 == null ? void 0 : moduleResolutionCache2.getPackageJsonInfoCache(), host2, options2);
118325
- const languageVersion = getEmitScriptTarget(options2);
118326
- const setExternalModuleIndicator2 = getSetExternalModuleIndicator(options2);
118366
+ function getImpliedNodeFormatForFile2(fileName) {
118367
+ let fileNameForModuleFormatDetection = getNormalizedAbsolutePath(fileName, currentDirectory);
118368
+ if (moduleFormatNeedsPackageJsonLookup(fileName, options)) {
118369
+ const projectReference = getResolvedProjectReferenceToRedirect(fileName);
118370
+ if (projectReference) {
118371
+ Debug.assert(useSourceOfProjectReferenceRedirect);
118372
+ fileNameForModuleFormatDetection = getOutputDeclarationFileName(
118373
+ fileNameForModuleFormatDetection,
118374
+ projectReference.commandLine,
118375
+ !host.useCaseSensitiveFileNames()
118376
+ ) || getOutputJSFileName(
118377
+ fileNameForModuleFormatDetection,
118378
+ projectReference.commandLine,
118379
+ !host.useCaseSensitiveFileNames()
118380
+ ) || fileNameForModuleFormatDetection;
118381
+ } else {
118382
+ fileNameForModuleFormatDetection = getOutputDeclarationFileNameWithoutConfigFile(
118383
+ fileNameForModuleFormatDetection,
118384
+ options,
118385
+ !host.useCaseSensitiveFileNames(),
118386
+ currentDirectory,
118387
+ getAssumedCommonSourceDirectory
118388
+ ) || getOutputJSFileNameWithoutConfigFile(
118389
+ fileNameForModuleFormatDetection,
118390
+ options,
118391
+ !host.useCaseSensitiveFileNames(),
118392
+ currentDirectory,
118393
+ getAssumedCommonSourceDirectory
118394
+ ) || fileNameForModuleFormatDetection;
118395
+ }
118396
+ }
118397
+ return getImpliedNodeFormatForFileWorker(
118398
+ fileNameForModuleFormatDetection,
118399
+ moduleResolutionCache == null ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(),
118400
+ host,
118401
+ options
118402
+ );
118403
+ }
118404
+ function getCreateSourceFileOptions(fileName) {
118405
+ const result = getImpliedNodeFormatForFile2(fileName);
118406
+ const languageVersion = getEmitScriptTarget(options);
118407
+ const setExternalModuleIndicator2 = getSetExternalModuleIndicator(options);
118327
118408
  return typeof result === "object" ? { ...result, languageVersion, setExternalModuleIndicator: setExternalModuleIndicator2 } : { languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator2 };
118328
118409
  }
118329
118410
  function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
@@ -118395,7 +118476,7 @@ ${lanes.join("\n")}
118395
118476
  redirectedPath = toPath3(redirect);
118396
118477
  }
118397
118478
  }
118398
- const sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options);
118479
+ const sourceFileOptions = getCreateSourceFileOptions(fileName);
118399
118480
  const file = host.getSourceFile(
118400
118481
  fileName,
118401
118482
  sourceFileOptions,
@@ -119018,6 +119099,9 @@ ${lanes.join("\n")}
119018
119099
  createDiagnosticForOptionName(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir");
119019
119100
  }
119020
119101
  }
119102
+ if (assumedCommonSourceDirectory && assumedCommonSourceDirectory !== getCommonSourceDirectory2()) {
119103
+ 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));
119104
+ }
119021
119105
  if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) {
119022
119106
  createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields");
119023
119107
  }
@@ -170560,8 +170644,11 @@ ${options.prefix}` : "\n" : options.prefix
170560
170644
  getOriginalNodeId: () => getOriginalNodeId,
170561
170645
  getOriginalSourceFile: () => getOriginalSourceFile,
170562
170646
  getOutputDeclarationFileName: () => getOutputDeclarationFileName,
170647
+ getOutputDeclarationFileNameWithoutConfigFile: () => getOutputDeclarationFileNameWithoutConfigFile,
170563
170648
  getOutputExtension: () => getOutputExtension,
170564
170649
  getOutputFileNames: () => getOutputFileNames,
170650
+ getOutputJSFileName: () => getOutputJSFileName,
170651
+ getOutputJSFileNameWithoutConfigFile: () => getOutputJSFileNameWithoutConfigFile,
170565
170652
  getOutputPathsFor: () => getOutputPathsFor,
170566
170653
  getOutputPathsForBundle: () => getOutputPathsForBundle,
170567
170654
  getOwnEmitOutputFilePath: () => getOwnEmitOutputFilePath,
@@ -5512,6 +5512,7 @@ var Diagnostics = {
5512
5512
  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."),
5513
5513
  Add_extends_constraint: diag(2211, 3 /* Message */, "Add_extends_constraint_2211", "Add `extends` constraint."),
5514
5514
  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"),
5515
+ 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."),
5515
5516
  Duplicate_identifier_0: diag(2300, 1 /* Error */, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
5516
5517
  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."),
5517
5518
  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."),
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typescript-deploys/pr-build",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.2.0-pr-54536-13",
5
+ "version": "5.2.0-pr-54546-4",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -115,5 +115,5 @@
115
115
  "node": "20.1.0",
116
116
  "npm": "8.19.4"
117
117
  },
118
- "gitHead": "014d2271f382640d52e637d4b56b59776ff166fa"
118
+ "gitHead": "446ee953056bfa863934a25998e0655dfd8cbac3"
119
119
  }