typescript 5.5.0-dev.20240416 → 5.5.0-dev.20240418

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.5";
21
- var version = `${versionMajorMinor}.0-dev.20240416`;
21
+ var version = `${versionMajorMinor}.0-dev.20240418`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -9175,11 +9175,6 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9175
9175
  }
9176
9176
  const ch = codePointAt(text, pos);
9177
9177
  if (pos === 0) {
9178
- if (text.slice(0, 256).includes("\uFFFD")) {
9179
- error(Diagnostics.File_appears_to_be_binary);
9180
- pos = end;
9181
- return token = 8 /* NonTextFileMarkerTrivia */;
9182
- }
9183
9178
  if (ch === 35 /* hash */ && isShebangTrivia(text, pos)) {
9184
9179
  pos = scanShebangTrivia(text, pos);
9185
9180
  if (skipTrivia2) {
@@ -9603,6 +9598,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9603
9598
  error(Diagnostics.Invalid_character, pos++, charSize(ch));
9604
9599
  }
9605
9600
  return token = 81 /* PrivateIdentifier */;
9601
+ case 65533 /* replacementCharacter */:
9602
+ error(Diagnostics.File_appears_to_be_binary, 0, 0);
9603
+ pos = end;
9604
+ return token = 8 /* NonTextFileMarkerTrivia */;
9606
9605
  default:
9607
9606
  const identifierKind = scanIdentifier(ch, languageVersion);
9608
9607
  if (identifierKind) {
@@ -34483,6 +34482,7 @@ var optionsForWatch = [
34483
34482
  isFilePath: true,
34484
34483
  extraValidation: specToDiagnostic
34485
34484
  },
34485
+ allowConfigDirTemplateSubstitution: true,
34486
34486
  category: Diagnostics.Watch_and_Build_Modes,
34487
34487
  description: Diagnostics.Remove_a_list_of_directories_from_the_watch_process
34488
34488
  },
@@ -34495,6 +34495,7 @@ var optionsForWatch = [
34495
34495
  isFilePath: true,
34496
34496
  extraValidation: specToDiagnostic
34497
34497
  },
34498
+ allowConfigDirTemplateSubstitution: true,
34498
34499
  category: Diagnostics.Watch_and_Build_Modes,
34499
34500
  description: Diagnostics.Remove_a_list_of_files_from_the_watch_mode_s_processing
34500
34501
  }
@@ -35193,6 +35194,7 @@ var commandOptionsWithoutBuild = [
35193
35194
  name: "paths",
35194
35195
  type: "object",
35195
35196
  affectsModuleResolution: true,
35197
+ allowConfigDirTemplateSubstitution: true,
35196
35198
  isTSConfigOnly: true,
35197
35199
  category: Diagnostics.Modules,
35198
35200
  description: Diagnostics.Specify_a_set_of_entries_that_re_map_imports_to_additional_lookup_locations,
@@ -35210,6 +35212,7 @@ var commandOptionsWithoutBuild = [
35210
35212
  isFilePath: true
35211
35213
  },
35212
35214
  affectsModuleResolution: true,
35215
+ allowConfigDirTemplateSubstitution: true,
35213
35216
  category: Diagnostics.Modules,
35214
35217
  description: Diagnostics.Allow_multiple_folders_to_be_treated_as_one_when_resolving_modules,
35215
35218
  transpileOptionValue: void 0,
@@ -35224,6 +35227,7 @@ var commandOptionsWithoutBuild = [
35224
35227
  isFilePath: true
35225
35228
  },
35226
35229
  affectsModuleResolution: true,
35230
+ allowConfigDirTemplateSubstitution: true,
35227
35231
  category: Diagnostics.Modules,
35228
35232
  description: Diagnostics.Specify_multiple_folders_that_act_like_Slashnode_modules_Slash_types
35229
35233
  },
@@ -35738,6 +35742,12 @@ var moduleResolutionOptionDeclarations = optionDeclarations.filter((option) => !
35738
35742
  var sourceFileAffectingCompilerOptions = optionDeclarations.filter((option) => !!option.affectsSourceFile || !!option.affectsBindDiagnostics);
35739
35743
  var optionsAffectingProgramStructure = optionDeclarations.filter((option) => !!option.affectsProgramStructure);
35740
35744
  var transpileOptionValueCompilerOptions = optionDeclarations.filter((option) => hasProperty(option, "transpileOptionValue"));
35745
+ var configDirTemplateSubstitutionOptions = optionDeclarations.filter(
35746
+ (option) => option.allowConfigDirTemplateSubstitution || !option.isCommandLineOnly && option.isFilePath
35747
+ );
35748
+ var configDirTemplateSubstitutionWatchOptions = optionsForWatch.filter(
35749
+ (option) => option.allowConfigDirTemplateSubstitution || !option.isCommandLineOnly && option.isFilePath
35750
+ );
35741
35751
  var optionsForBuild = [
35742
35752
  {
35743
35753
  name: "verbose",
@@ -36521,6 +36531,8 @@ function serializeOptionBaseObject(options, { optionsNameMap }, pathOptions) {
36521
36531
  if (!customTypeMap) {
36522
36532
  if (pathOptions && optionDefinition.isFilePath) {
36523
36533
  result.set(name, getRelativePathFromFile(pathOptions.configFilePath, getNormalizedAbsolutePath(value, getDirectoryPath(pathOptions.configFilePath)), getCanonicalFileName));
36534
+ } else if (pathOptions && optionDefinition.type === "list" && optionDefinition.element.isFilePath) {
36535
+ result.set(name, value.map((v) => getRelativePathFromFile(pathOptions.configFilePath, getNormalizedAbsolutePath(v, getDirectoryPath(pathOptions.configFilePath)), getCanonicalFileName)));
36524
36536
  } else {
36525
36537
  result.set(name, value);
36526
36538
  }
@@ -36705,14 +36717,21 @@ function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, exis
36705
36717
  const errors = [];
36706
36718
  const parsedConfig = parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors, extendedConfigCache);
36707
36719
  const { raw } = parsedConfig;
36708
- const options = extend(existingOptions, parsedConfig.options || {});
36709
- const watchOptions = existingWatchOptions && parsedConfig.watchOptions ? extend(existingWatchOptions, parsedConfig.watchOptions) : parsedConfig.watchOptions || existingWatchOptions;
36720
+ const options = handleOptionConfigDirTemplateSubstitution(
36721
+ extend(existingOptions, parsedConfig.options || {}),
36722
+ configDirTemplateSubstitutionOptions,
36723
+ basePath
36724
+ );
36725
+ const watchOptions = handleWatchOptionsConfigDirTemplateSubstitution(
36726
+ existingWatchOptions && parsedConfig.watchOptions ? extend(existingWatchOptions, parsedConfig.watchOptions) : parsedConfig.watchOptions || existingWatchOptions,
36727
+ basePath
36728
+ );
36710
36729
  options.configFilePath = configFileName && normalizeSlashes(configFileName);
36730
+ const basePathForFileNames = normalizePath(configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath);
36711
36731
  const configFileSpecs = getConfigFileSpecs();
36712
36732
  if (sourceFile)
36713
36733
  sourceFile.configFileSpecs = configFileSpecs;
36714
36734
  setConfigFileInOptions(options, sourceFile);
36715
- const basePathForFileNames = normalizePath(configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath);
36716
36735
  return {
36717
36736
  options,
36718
36737
  watchOptions,
@@ -36761,9 +36780,10 @@ function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, exis
36761
36780
  includeSpecs = [defaultIncludeSpec];
36762
36781
  isDefaultIncludeSpec = true;
36763
36782
  }
36783
+ let validatedIncludeSpecsBeforeSubstitution, validatedExcludeSpecsBeforeSubstitution;
36764
36784
  let validatedIncludeSpecs, validatedExcludeSpecs;
36765
36785
  if (includeSpecs) {
36766
- validatedIncludeSpecs = validateSpecs(
36786
+ validatedIncludeSpecsBeforeSubstitution = validateSpecs(
36767
36787
  includeSpecs,
36768
36788
  errors,
36769
36789
  /*disallowTrailingRecursion*/
@@ -36771,9 +36791,13 @@ function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, exis
36771
36791
  sourceFile,
36772
36792
  "include"
36773
36793
  );
36794
+ validatedIncludeSpecs = getSubstitutedStringArrayWithConfigDirTemplate(
36795
+ validatedIncludeSpecsBeforeSubstitution,
36796
+ basePathForFileNames
36797
+ ) || validatedIncludeSpecsBeforeSubstitution;
36774
36798
  }
36775
36799
  if (excludeSpecs) {
36776
- validatedExcludeSpecs = validateSpecs(
36800
+ validatedExcludeSpecsBeforeSubstitution = validateSpecs(
36777
36801
  excludeSpecs,
36778
36802
  errors,
36779
36803
  /*disallowTrailingRecursion*/
@@ -36781,14 +36805,26 @@ function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, exis
36781
36805
  sourceFile,
36782
36806
  "exclude"
36783
36807
  );
36808
+ validatedExcludeSpecs = getSubstitutedStringArrayWithConfigDirTemplate(
36809
+ validatedExcludeSpecsBeforeSubstitution,
36810
+ basePathForFileNames
36811
+ ) || validatedExcludeSpecsBeforeSubstitution;
36784
36812
  }
36813
+ const validatedFilesSpecBeforeSubstitution = filter(filesSpecs, isString);
36814
+ const validatedFilesSpec = getSubstitutedStringArrayWithConfigDirTemplate(
36815
+ validatedFilesSpecBeforeSubstitution,
36816
+ basePathForFileNames
36817
+ ) || validatedFilesSpecBeforeSubstitution;
36785
36818
  return {
36786
36819
  filesSpecs,
36787
36820
  includeSpecs,
36788
36821
  excludeSpecs,
36789
- validatedFilesSpec: filter(filesSpecs, isString),
36822
+ validatedFilesSpec,
36790
36823
  validatedIncludeSpecs,
36791
36824
  validatedExcludeSpecs,
36825
+ validatedFilesSpecBeforeSubstitution,
36826
+ validatedIncludeSpecsBeforeSubstitution,
36827
+ validatedExcludeSpecsBeforeSubstitution,
36792
36828
  pathPatterns: void 0,
36793
36829
  // Initialized on first use
36794
36830
  isDefaultIncludeSpec
@@ -36847,6 +36883,81 @@ function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, exis
36847
36883
  }
36848
36884
  }
36849
36885
  }
36886
+ function handleWatchOptionsConfigDirTemplateSubstitution(watchOptions, basePath) {
36887
+ return handleOptionConfigDirTemplateSubstitution(watchOptions, configDirTemplateSubstitutionWatchOptions, basePath);
36888
+ }
36889
+ function handleOptionConfigDirTemplateSubstitution(options, optionDeclarations2, basePath) {
36890
+ if (!options)
36891
+ return options;
36892
+ let result;
36893
+ for (const option of optionDeclarations2) {
36894
+ if (options[option.name] !== void 0) {
36895
+ const value = options[option.name];
36896
+ switch (option.type) {
36897
+ case "string":
36898
+ Debug.assert(option.isFilePath);
36899
+ if (startsWithConfigDirTemplate(value)) {
36900
+ setOptionValue(option, getSubstitutedPathWithConfigDirTemplate(value, basePath));
36901
+ }
36902
+ break;
36903
+ case "list":
36904
+ Debug.assert(option.element.isFilePath);
36905
+ const listResult = getSubstitutedStringArrayWithConfigDirTemplate(value, basePath);
36906
+ if (listResult)
36907
+ setOptionValue(option, listResult);
36908
+ break;
36909
+ case "object":
36910
+ Debug.assert(option.name === "paths");
36911
+ const objectResult = getSubstitutedMapLikeOfStringArrayWithConfigDirTemplate(value, basePath);
36912
+ if (objectResult)
36913
+ setOptionValue(option, objectResult);
36914
+ break;
36915
+ default:
36916
+ Debug.fail("option type not supported");
36917
+ }
36918
+ }
36919
+ }
36920
+ return result || options;
36921
+ function setOptionValue(option, value) {
36922
+ (result ?? (result = assign({}, options)))[option.name] = value;
36923
+ }
36924
+ }
36925
+ var configDirTemplate = `\${configDir}`;
36926
+ function startsWithConfigDirTemplate(value) {
36927
+ return isString(value) && startsWith(
36928
+ value,
36929
+ configDirTemplate,
36930
+ /*ignoreCase*/
36931
+ true
36932
+ );
36933
+ }
36934
+ function getSubstitutedPathWithConfigDirTemplate(value, basePath) {
36935
+ return getNormalizedAbsolutePath(value.replace(configDirTemplate, "./"), basePath);
36936
+ }
36937
+ function getSubstitutedStringArrayWithConfigDirTemplate(list, basePath) {
36938
+ if (!list)
36939
+ return list;
36940
+ let result;
36941
+ list.forEach((element, index) => {
36942
+ if (!startsWithConfigDirTemplate(element))
36943
+ return;
36944
+ (result ?? (result = list.slice()))[index] = getSubstitutedPathWithConfigDirTemplate(element, basePath);
36945
+ });
36946
+ return result;
36947
+ }
36948
+ function getSubstitutedMapLikeOfStringArrayWithConfigDirTemplate(mapLike, basePath) {
36949
+ let result;
36950
+ const ownKeys = getOwnKeys(mapLike);
36951
+ ownKeys.forEach((key) => {
36952
+ if (!isArray(mapLike[key]))
36953
+ return;
36954
+ const subStitution = getSubstitutedStringArrayWithConfigDirTemplate(mapLike[key], basePath);
36955
+ if (!subStitution)
36956
+ return;
36957
+ (result ?? (result = assign({}, mapLike)))[key] = subStitution;
36958
+ });
36959
+ return result;
36960
+ }
36850
36961
  function isErrorNoInputFiles(error) {
36851
36962
  return error.code === Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code;
36852
36963
  }
@@ -36896,11 +37007,11 @@ function parseConfig(json, sourceFile, host, basePath, configFileName, resolutio
36896
37007
  } else {
36897
37008
  ownConfig.extendedConfigPath.forEach((extendedConfigPath) => applyExtendedConfig(result, extendedConfigPath));
36898
37009
  }
36899
- if (!ownConfig.raw.include && result.include)
37010
+ if (result.include)
36900
37011
  ownConfig.raw.include = result.include;
36901
- if (!ownConfig.raw.exclude && result.exclude)
37012
+ if (result.exclude)
36902
37013
  ownConfig.raw.exclude = result.exclude;
36903
- if (!ownConfig.raw.files && result.files)
37014
+ if (result.files)
36904
37015
  ownConfig.raw.files = result.files;
36905
37016
  if (ownConfig.raw.compileOnSave === void 0 && result.compileOnSave)
36906
37017
  ownConfig.raw.compileOnSave = result.compileOnSave;
@@ -36916,8 +37027,10 @@ function parseConfig(json, sourceFile, host, basePath, configFileName, resolutio
36916
37027
  const extendsRaw = extendedConfig.raw;
36917
37028
  let relativeDifference;
36918
37029
  const setPropertyInResultIfNotUndefined = (propertyName) => {
37030
+ if (ownConfig.raw[propertyName])
37031
+ return;
36919
37032
  if (extendsRaw[propertyName]) {
36920
- result[propertyName] = map(extendsRaw[propertyName], (path) => isRootedDiskPath(path) ? path : combinePaths(
37033
+ result[propertyName] = map(extendsRaw[propertyName], (path) => startsWithConfigDirTemplate(path) || isRootedDiskPath(path) ? path : combinePaths(
36921
37034
  relativeDifference || (relativeDifference = convertToRelativePath(getDirectoryPath(extendedConfigPath), basePath, createGetCanonicalFileName(host.useCaseSensitiveFileNames))),
36922
37035
  path
36923
37036
  ));
@@ -37185,7 +37298,8 @@ function convertJsonOption(opt, value, basePath, errors, propertyAssignment, val
37185
37298
  }
37186
37299
  function normalizeNonListOptionValue(option, basePath, value) {
37187
37300
  if (option.isFilePath) {
37188
- value = getNormalizedAbsolutePath(value, basePath);
37301
+ value = normalizeSlashes(value);
37302
+ value = !startsWithConfigDirTemplate(value) ? getNormalizedAbsolutePath(value, basePath) : value;
37189
37303
  if (value === "") {
37190
37304
  value = ".";
37191
37305
  }
@@ -44909,7 +45023,6 @@ function createTypeChecker(host) {
44909
45023
  };
44910
45024
  var amalgamatedDuplicates;
44911
45025
  var reverseMappedCache = /* @__PURE__ */ new Map();
44912
- var homomorphicMappedTypeInferenceStack = [];
44913
45026
  var ambientModulesCache;
44914
45027
  var patternAmbientModules;
44915
45028
  var patternAmbientModuleAugmentations;
@@ -45010,6 +45123,9 @@ function createTypeChecker(host) {
45010
45123
  var potentialReflectCollisions = [];
45011
45124
  var potentialUnusedRenamedBindingElementsInTypes = [];
45012
45125
  var awaitedTypeStack = [];
45126
+ var reverseMappedSourceStack = [];
45127
+ var reverseMappedTargetStack = [];
45128
+ var reverseExpandingFlags = 0 /* None */;
45013
45129
  var diagnostics = createDiagnosticCollection();
45014
45130
  var suggestionDiagnostics = createDiagnosticCollection();
45015
45131
  var typeofType = createTypeofType();
@@ -53093,7 +53209,7 @@ function createTypeChecker(host) {
53093
53209
  result.aliasTypeArguments = length(args) ? args : void 0;
53094
53210
  }
53095
53211
  }
53096
- result.objectFlags |= getObjectFlags(type) & 4096 /* JSLiteral */;
53212
+ result.objectFlags |= getPropagatingFlagsOfTypes([type]) | getObjectFlags(type) & (4096 /* JSLiteral */ | 16384 /* ArrayLiteral */ | 128 /* ObjectLiteral */);
53097
53213
  if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) {
53098
53214
  result.objectFlags |= 16777216 /* IsClassInstanceClone */;
53099
53215
  }
@@ -55039,7 +55155,7 @@ function createTypeChecker(host) {
55039
55155
  const modifiers = getMappedTypeModifiers(type.mappedType);
55040
55156
  const readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true;
55041
55157
  const optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */;
55042
- const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : emptyArray;
55158
+ const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType) || unknownType, readonlyMask && indexInfo.isReadonly)] : emptyArray;
55043
55159
  const members = createSymbolTable();
55044
55160
  const limitedConstraint = getLimitedConstraint(type);
55045
55161
  for (const prop of getPropertiesOfType(type.source)) {
@@ -64859,13 +64975,7 @@ function createTypeChecker(host) {
64859
64975
  if (reverseMappedCache.has(cacheKey)) {
64860
64976
  return reverseMappedCache.get(cacheKey);
64861
64977
  }
64862
- const recursionKey = source.id + "," + (target.target || target).id;
64863
- if (contains(homomorphicMappedTypeInferenceStack, recursionKey)) {
64864
- return void 0;
64865
- }
64866
- homomorphicMappedTypeInferenceStack.push(recursionKey);
64867
64978
  const type = createReverseMappedType(source, target, constraint);
64868
- homomorphicMappedTypeInferenceStack.pop();
64869
64979
  reverseMappedCache.set(cacheKey, type);
64870
64980
  return type;
64871
64981
  }
@@ -64877,10 +64987,17 @@ function createTypeChecker(host) {
64877
64987
  return void 0;
64878
64988
  }
64879
64989
  if (isArrayType(source)) {
64880
- return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source));
64990
+ const elementType = inferReverseMappedType(getTypeArguments(source)[0], target, constraint);
64991
+ if (!elementType) {
64992
+ return void 0;
64993
+ }
64994
+ return createArrayType(elementType, isReadonlyArrayType(source));
64881
64995
  }
64882
64996
  if (isTupleType(source)) {
64883
64997
  const elementTypes = map(getElementTypes(source), (t) => inferReverseMappedType(t, target, constraint));
64998
+ if (!every(elementTypes, (t) => !!t)) {
64999
+ return void 0;
65000
+ }
64884
65001
  const elementFlags = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? sameMap(source.target.elementFlags, (f) => f & 2 /* Optional */ ? 1 /* Required */ : f) : source.target.elementFlags;
64885
65002
  return createTupleType(elementTypes, elementFlags, source.target.readonly, source.target.labeledElementDeclarations);
64886
65003
  }
@@ -64897,17 +65014,39 @@ function createTypeChecker(host) {
64897
65014
  function getTypeOfReverseMappedSymbol(symbol) {
64898
65015
  const links = getSymbolLinks(symbol);
64899
65016
  if (!links.type) {
64900
- links.type = inferReverseMappedType(symbol.links.propertyType, symbol.links.mappedType, symbol.links.constraintType);
65017
+ links.type = inferReverseMappedType(symbol.links.propertyType, symbol.links.mappedType, symbol.links.constraintType) || unknownType;
64901
65018
  }
64902
65019
  return links.type;
64903
65020
  }
64904
- function inferReverseMappedType(sourceType, target, constraint) {
65021
+ function inferReverseMappedTypeWorker(sourceType, target, constraint) {
64905
65022
  const typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target));
64906
65023
  const templateType = getTemplateTypeFromMappedType(target);
64907
65024
  const inference = createInferenceInfo(typeParameter);
64908
65025
  inferTypes([inference], sourceType, templateType);
64909
65026
  return getTypeFromInference(inference) || unknownType;
64910
65027
  }
65028
+ function inferReverseMappedType(source, target, constraint) {
65029
+ const cacheKey = source.id + "," + target.id + "," + constraint.id;
65030
+ if (reverseMappedCache.has(cacheKey)) {
65031
+ return reverseMappedCache.get(cacheKey) || unknownType;
65032
+ }
65033
+ reverseMappedSourceStack.push(source);
65034
+ reverseMappedTargetStack.push(target);
65035
+ const saveExpandingFlags = reverseExpandingFlags;
65036
+ if (isDeeplyNestedType(source, reverseMappedSourceStack, reverseMappedSourceStack.length, 2))
65037
+ reverseExpandingFlags |= 1 /* Source */;
65038
+ if (isDeeplyNestedType(target, reverseMappedTargetStack, reverseMappedTargetStack.length, 2))
65039
+ reverseExpandingFlags |= 2 /* Target */;
65040
+ let type;
65041
+ if (reverseExpandingFlags !== 3 /* Both */) {
65042
+ type = inferReverseMappedTypeWorker(source, target, constraint);
65043
+ }
65044
+ reverseMappedSourceStack.pop();
65045
+ reverseMappedTargetStack.pop();
65046
+ reverseExpandingFlags = saveExpandingFlags;
65047
+ reverseMappedCache.set(cacheKey, type);
65048
+ return type;
65049
+ }
64911
65050
  function* getUnmatchedProperties(source, target, requireOptionalProperties, matchDiscriminantProperties) {
64912
65051
  const properties = getPropertiesOfType(target);
64913
65052
  for (const targetProp of properties) {
@@ -123525,7 +123664,8 @@ function getMatchedFileSpec(program, fileName) {
123525
123664
  return void 0;
123526
123665
  const filePath = program.getCanonicalFileName(fileName);
123527
123666
  const basePath = getDirectoryPath(getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory()));
123528
- return find(configFile.configFileSpecs.validatedFilesSpec, (fileSpec) => program.getCanonicalFileName(getNormalizedAbsolutePath(fileSpec, basePath)) === filePath);
123667
+ const index = findIndex(configFile.configFileSpecs.validatedFilesSpec, (fileSpec) => program.getCanonicalFileName(getNormalizedAbsolutePath(fileSpec, basePath)) === filePath);
123668
+ return index !== -1 ? configFile.configFileSpecs.validatedFilesSpecBeforeSubstitution[index] : void 0;
123529
123669
  }
123530
123670
  function getMatchedIncludeSpec(program, fileName) {
123531
123671
  var _a, _b;
@@ -123537,12 +123677,13 @@ function getMatchedIncludeSpec(program, fileName) {
123537
123677
  const isJsonFile = fileExtensionIs(fileName, ".json" /* Json */);
123538
123678
  const basePath = getDirectoryPath(getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory()));
123539
123679
  const useCaseSensitiveFileNames2 = program.useCaseSensitiveFileNames();
123540
- return find((_b = configFile == null ? void 0 : configFile.configFileSpecs) == null ? void 0 : _b.validatedIncludeSpecs, (includeSpec) => {
123680
+ const index = findIndex((_b = configFile == null ? void 0 : configFile.configFileSpecs) == null ? void 0 : _b.validatedIncludeSpecs, (includeSpec) => {
123541
123681
  if (isJsonFile && !endsWith(includeSpec, ".json" /* Json */))
123542
123682
  return false;
123543
123683
  const pattern = getPatternFromSpec(includeSpec, basePath, "files");
123544
123684
  return !!pattern && getRegexFromPattern(`(${pattern})$`, useCaseSensitiveFileNames2).test(fileName);
123545
123685
  });
123686
+ return index !== -1 ? configFile.configFileSpecs.validatedIncludeSpecsBeforeSubstitution[index] : void 0;
123546
123687
  }
123547
123688
  function fileIncludeReasonToDiagnostics(program, reason, fileNameConvertor) {
123548
123689
  var _a, _b;
@@ -4378,12 +4378,6 @@ declare namespace ts {
4378
4378
  interface Identifier {
4379
4379
  readonly text: string;
4380
4380
  }
4381
- interface Identifier {
4382
- /** @deprecated Use `idKeyword(identifier)` instead. */
4383
- readonly originalKeywordKind?: SyntaxKind;
4384
- /** @deprecated Use `.parent` or the surrounding context to determine this instead. */
4385
- readonly isInJSDocNamespace?: boolean;
4386
- }
4387
4381
  interface TransientIdentifier extends Identifier {
4388
4382
  resolvedSymbol: Symbol;
4389
4383
  }
package/lib/typescript.js CHANGED
@@ -339,6 +339,8 @@ __export(typescript_exports, {
339
339
  computedOptions: () => computedOptions,
340
340
  concatenate: () => concatenate,
341
341
  concatenateDiagnosticMessageChains: () => concatenateDiagnosticMessageChains,
342
+ configDirTemplateSubstitutionOptions: () => configDirTemplateSubstitutionOptions,
343
+ configDirTemplateSubstitutionWatchOptions: () => configDirTemplateSubstitutionWatchOptions,
342
344
  consumesNodeCoreModules: () => consumesNodeCoreModules,
343
345
  contains: () => contains,
344
346
  containsIgnoredPath: () => containsIgnoredPath,
@@ -1109,6 +1111,7 @@ __export(typescript_exports, {
1109
1111
  groupBy: () => groupBy,
1110
1112
  guessIndentation: () => guessIndentation,
1111
1113
  handleNoEmitOptions: () => handleNoEmitOptions,
1114
+ handleWatchOptionsConfigDirTemplateSubstitution: () => handleWatchOptionsConfigDirTemplateSubstitution,
1112
1115
  hasAbstractModifier: () => hasAbstractModifier,
1113
1116
  hasAccessorModifier: () => hasAccessorModifier,
1114
1117
  hasAmbientModifier: () => hasAmbientModifier,
@@ -2347,7 +2350,7 @@ module.exports = __toCommonJS(typescript_exports);
2347
2350
 
2348
2351
  // src/compiler/corePublic.ts
2349
2352
  var versionMajorMinor = "5.5";
2350
- var version = `${versionMajorMinor}.0-dev.20240416`;
2353
+ var version = `${versionMajorMinor}.0-dev.20240418`;
2351
2354
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2352
2355
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2353
2356
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -7009,6 +7012,7 @@ var CharacterCodes = /* @__PURE__ */ ((CharacterCodes2) => {
7009
7012
  CharacterCodes2[CharacterCodes2["ideographicSpace"] = 12288] = "ideographicSpace";
7010
7013
  CharacterCodes2[CharacterCodes2["mathematicalSpace"] = 8287] = "mathematicalSpace";
7011
7014
  CharacterCodes2[CharacterCodes2["ogham"] = 5760] = "ogham";
7015
+ CharacterCodes2[CharacterCodes2["replacementCharacter"] = 65533] = "replacementCharacter";
7012
7016
  CharacterCodes2[CharacterCodes2["_"] = 95] = "_";
7013
7017
  CharacterCodes2[CharacterCodes2["$"] = 36] = "$";
7014
7018
  CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
@@ -12773,11 +12777,6 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12773
12777
  }
12774
12778
  const ch = codePointAt(text, pos);
12775
12779
  if (pos === 0) {
12776
- if (text.slice(0, 256).includes("\uFFFD")) {
12777
- error2(Diagnostics.File_appears_to_be_binary);
12778
- pos = end;
12779
- return token = 8 /* NonTextFileMarkerTrivia */;
12780
- }
12781
12780
  if (ch === 35 /* hash */ && isShebangTrivia(text, pos)) {
12782
12781
  pos = scanShebangTrivia(text, pos);
12783
12782
  if (skipTrivia2) {
@@ -13201,6 +13200,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13201
13200
  error2(Diagnostics.Invalid_character, pos++, charSize(ch));
13202
13201
  }
13203
13202
  return token = 81 /* PrivateIdentifier */;
13203
+ case 65533 /* replacementCharacter */:
13204
+ error2(Diagnostics.File_appears_to_be_binary, 0, 0);
13205
+ pos = end;
13206
+ return token = 8 /* NonTextFileMarkerTrivia */;
13204
13207
  default:
13205
13208
  const identifierKind = scanIdentifier(ch, languageVersion);
13206
13209
  if (identifierKind) {
@@ -38925,6 +38928,7 @@ var optionsForWatch = [
38925
38928
  isFilePath: true,
38926
38929
  extraValidation: specToDiagnostic
38927
38930
  },
38931
+ allowConfigDirTemplateSubstitution: true,
38928
38932
  category: Diagnostics.Watch_and_Build_Modes,
38929
38933
  description: Diagnostics.Remove_a_list_of_directories_from_the_watch_process
38930
38934
  },
@@ -38937,6 +38941,7 @@ var optionsForWatch = [
38937
38941
  isFilePath: true,
38938
38942
  extraValidation: specToDiagnostic
38939
38943
  },
38944
+ allowConfigDirTemplateSubstitution: true,
38940
38945
  category: Diagnostics.Watch_and_Build_Modes,
38941
38946
  description: Diagnostics.Remove_a_list_of_files_from_the_watch_mode_s_processing
38942
38947
  }
@@ -39635,6 +39640,7 @@ var commandOptionsWithoutBuild = [
39635
39640
  name: "paths",
39636
39641
  type: "object",
39637
39642
  affectsModuleResolution: true,
39643
+ allowConfigDirTemplateSubstitution: true,
39638
39644
  isTSConfigOnly: true,
39639
39645
  category: Diagnostics.Modules,
39640
39646
  description: Diagnostics.Specify_a_set_of_entries_that_re_map_imports_to_additional_lookup_locations,
@@ -39652,6 +39658,7 @@ var commandOptionsWithoutBuild = [
39652
39658
  isFilePath: true
39653
39659
  },
39654
39660
  affectsModuleResolution: true,
39661
+ allowConfigDirTemplateSubstitution: true,
39655
39662
  category: Diagnostics.Modules,
39656
39663
  description: Diagnostics.Allow_multiple_folders_to_be_treated_as_one_when_resolving_modules,
39657
39664
  transpileOptionValue: void 0,
@@ -39666,6 +39673,7 @@ var commandOptionsWithoutBuild = [
39666
39673
  isFilePath: true
39667
39674
  },
39668
39675
  affectsModuleResolution: true,
39676
+ allowConfigDirTemplateSubstitution: true,
39669
39677
  category: Diagnostics.Modules,
39670
39678
  description: Diagnostics.Specify_multiple_folders_that_act_like_Slashnode_modules_Slash_types
39671
39679
  },
@@ -40180,6 +40188,12 @@ var moduleResolutionOptionDeclarations = optionDeclarations.filter((option) => !
40180
40188
  var sourceFileAffectingCompilerOptions = optionDeclarations.filter((option) => !!option.affectsSourceFile || !!option.affectsBindDiagnostics);
40181
40189
  var optionsAffectingProgramStructure = optionDeclarations.filter((option) => !!option.affectsProgramStructure);
40182
40190
  var transpileOptionValueCompilerOptions = optionDeclarations.filter((option) => hasProperty(option, "transpileOptionValue"));
40191
+ var configDirTemplateSubstitutionOptions = optionDeclarations.filter(
40192
+ (option) => option.allowConfigDirTemplateSubstitution || !option.isCommandLineOnly && option.isFilePath
40193
+ );
40194
+ var configDirTemplateSubstitutionWatchOptions = optionsForWatch.filter(
40195
+ (option) => option.allowConfigDirTemplateSubstitution || !option.isCommandLineOnly && option.isFilePath
40196
+ );
40183
40197
  var optionsForBuild = [
40184
40198
  {
40185
40199
  name: "verbose",
@@ -40973,6 +40987,8 @@ function serializeOptionBaseObject(options, { optionsNameMap }, pathOptions) {
40973
40987
  if (!customTypeMap) {
40974
40988
  if (pathOptions && optionDefinition.isFilePath) {
40975
40989
  result.set(name, getRelativePathFromFile(pathOptions.configFilePath, getNormalizedAbsolutePath(value, getDirectoryPath(pathOptions.configFilePath)), getCanonicalFileName));
40990
+ } else if (pathOptions && optionDefinition.type === "list" && optionDefinition.element.isFilePath) {
40991
+ result.set(name, value.map((v) => getRelativePathFromFile(pathOptions.configFilePath, getNormalizedAbsolutePath(v, getDirectoryPath(pathOptions.configFilePath)), getCanonicalFileName)));
40976
40992
  } else {
40977
40993
  result.set(name, value);
40978
40994
  }
@@ -41172,14 +41188,21 @@ function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, exis
41172
41188
  const errors = [];
41173
41189
  const parsedConfig = parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors, extendedConfigCache);
41174
41190
  const { raw } = parsedConfig;
41175
- const options = extend(existingOptions, parsedConfig.options || {});
41176
- const watchOptions = existingWatchOptions && parsedConfig.watchOptions ? extend(existingWatchOptions, parsedConfig.watchOptions) : parsedConfig.watchOptions || existingWatchOptions;
41191
+ const options = handleOptionConfigDirTemplateSubstitution(
41192
+ extend(existingOptions, parsedConfig.options || {}),
41193
+ configDirTemplateSubstitutionOptions,
41194
+ basePath
41195
+ );
41196
+ const watchOptions = handleWatchOptionsConfigDirTemplateSubstitution(
41197
+ existingWatchOptions && parsedConfig.watchOptions ? extend(existingWatchOptions, parsedConfig.watchOptions) : parsedConfig.watchOptions || existingWatchOptions,
41198
+ basePath
41199
+ );
41177
41200
  options.configFilePath = configFileName && normalizeSlashes(configFileName);
41201
+ const basePathForFileNames = normalizePath(configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath);
41178
41202
  const configFileSpecs = getConfigFileSpecs();
41179
41203
  if (sourceFile)
41180
41204
  sourceFile.configFileSpecs = configFileSpecs;
41181
41205
  setConfigFileInOptions(options, sourceFile);
41182
- const basePathForFileNames = normalizePath(configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath);
41183
41206
  return {
41184
41207
  options,
41185
41208
  watchOptions,
@@ -41228,9 +41251,10 @@ function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, exis
41228
41251
  includeSpecs = [defaultIncludeSpec];
41229
41252
  isDefaultIncludeSpec = true;
41230
41253
  }
41254
+ let validatedIncludeSpecsBeforeSubstitution, validatedExcludeSpecsBeforeSubstitution;
41231
41255
  let validatedIncludeSpecs, validatedExcludeSpecs;
41232
41256
  if (includeSpecs) {
41233
- validatedIncludeSpecs = validateSpecs(
41257
+ validatedIncludeSpecsBeforeSubstitution = validateSpecs(
41234
41258
  includeSpecs,
41235
41259
  errors,
41236
41260
  /*disallowTrailingRecursion*/
@@ -41238,9 +41262,13 @@ function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, exis
41238
41262
  sourceFile,
41239
41263
  "include"
41240
41264
  );
41265
+ validatedIncludeSpecs = getSubstitutedStringArrayWithConfigDirTemplate(
41266
+ validatedIncludeSpecsBeforeSubstitution,
41267
+ basePathForFileNames
41268
+ ) || validatedIncludeSpecsBeforeSubstitution;
41241
41269
  }
41242
41270
  if (excludeSpecs) {
41243
- validatedExcludeSpecs = validateSpecs(
41271
+ validatedExcludeSpecsBeforeSubstitution = validateSpecs(
41244
41272
  excludeSpecs,
41245
41273
  errors,
41246
41274
  /*disallowTrailingRecursion*/
@@ -41248,14 +41276,26 @@ function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, exis
41248
41276
  sourceFile,
41249
41277
  "exclude"
41250
41278
  );
41279
+ validatedExcludeSpecs = getSubstitutedStringArrayWithConfigDirTemplate(
41280
+ validatedExcludeSpecsBeforeSubstitution,
41281
+ basePathForFileNames
41282
+ ) || validatedExcludeSpecsBeforeSubstitution;
41251
41283
  }
41284
+ const validatedFilesSpecBeforeSubstitution = filter(filesSpecs, isString);
41285
+ const validatedFilesSpec = getSubstitutedStringArrayWithConfigDirTemplate(
41286
+ validatedFilesSpecBeforeSubstitution,
41287
+ basePathForFileNames
41288
+ ) || validatedFilesSpecBeforeSubstitution;
41252
41289
  return {
41253
41290
  filesSpecs,
41254
41291
  includeSpecs,
41255
41292
  excludeSpecs,
41256
- validatedFilesSpec: filter(filesSpecs, isString),
41293
+ validatedFilesSpec,
41257
41294
  validatedIncludeSpecs,
41258
41295
  validatedExcludeSpecs,
41296
+ validatedFilesSpecBeforeSubstitution,
41297
+ validatedIncludeSpecsBeforeSubstitution,
41298
+ validatedExcludeSpecsBeforeSubstitution,
41259
41299
  pathPatterns: void 0,
41260
41300
  // Initialized on first use
41261
41301
  isDefaultIncludeSpec
@@ -41314,6 +41354,81 @@ function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, exis
41314
41354
  }
41315
41355
  }
41316
41356
  }
41357
+ function handleWatchOptionsConfigDirTemplateSubstitution(watchOptions, basePath) {
41358
+ return handleOptionConfigDirTemplateSubstitution(watchOptions, configDirTemplateSubstitutionWatchOptions, basePath);
41359
+ }
41360
+ function handleOptionConfigDirTemplateSubstitution(options, optionDeclarations2, basePath) {
41361
+ if (!options)
41362
+ return options;
41363
+ let result;
41364
+ for (const option of optionDeclarations2) {
41365
+ if (options[option.name] !== void 0) {
41366
+ const value = options[option.name];
41367
+ switch (option.type) {
41368
+ case "string":
41369
+ Debug.assert(option.isFilePath);
41370
+ if (startsWithConfigDirTemplate(value)) {
41371
+ setOptionValue(option, getSubstitutedPathWithConfigDirTemplate(value, basePath));
41372
+ }
41373
+ break;
41374
+ case "list":
41375
+ Debug.assert(option.element.isFilePath);
41376
+ const listResult = getSubstitutedStringArrayWithConfigDirTemplate(value, basePath);
41377
+ if (listResult)
41378
+ setOptionValue(option, listResult);
41379
+ break;
41380
+ case "object":
41381
+ Debug.assert(option.name === "paths");
41382
+ const objectResult = getSubstitutedMapLikeOfStringArrayWithConfigDirTemplate(value, basePath);
41383
+ if (objectResult)
41384
+ setOptionValue(option, objectResult);
41385
+ break;
41386
+ default:
41387
+ Debug.fail("option type not supported");
41388
+ }
41389
+ }
41390
+ }
41391
+ return result || options;
41392
+ function setOptionValue(option, value) {
41393
+ (result ?? (result = assign({}, options)))[option.name] = value;
41394
+ }
41395
+ }
41396
+ var configDirTemplate = `\${configDir}`;
41397
+ function startsWithConfigDirTemplate(value) {
41398
+ return isString(value) && startsWith(
41399
+ value,
41400
+ configDirTemplate,
41401
+ /*ignoreCase*/
41402
+ true
41403
+ );
41404
+ }
41405
+ function getSubstitutedPathWithConfigDirTemplate(value, basePath) {
41406
+ return getNormalizedAbsolutePath(value.replace(configDirTemplate, "./"), basePath);
41407
+ }
41408
+ function getSubstitutedStringArrayWithConfigDirTemplate(list, basePath) {
41409
+ if (!list)
41410
+ return list;
41411
+ let result;
41412
+ list.forEach((element, index) => {
41413
+ if (!startsWithConfigDirTemplate(element))
41414
+ return;
41415
+ (result ?? (result = list.slice()))[index] = getSubstitutedPathWithConfigDirTemplate(element, basePath);
41416
+ });
41417
+ return result;
41418
+ }
41419
+ function getSubstitutedMapLikeOfStringArrayWithConfigDirTemplate(mapLike, basePath) {
41420
+ let result;
41421
+ const ownKeys = getOwnKeys(mapLike);
41422
+ ownKeys.forEach((key) => {
41423
+ if (!isArray(mapLike[key]))
41424
+ return;
41425
+ const subStitution = getSubstitutedStringArrayWithConfigDirTemplate(mapLike[key], basePath);
41426
+ if (!subStitution)
41427
+ return;
41428
+ (result ?? (result = assign({}, mapLike)))[key] = subStitution;
41429
+ });
41430
+ return result;
41431
+ }
41317
41432
  function isErrorNoInputFiles(error2) {
41318
41433
  return error2.code === Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code;
41319
41434
  }
@@ -41363,11 +41478,11 @@ function parseConfig(json, sourceFile, host, basePath, configFileName, resolutio
41363
41478
  } else {
41364
41479
  ownConfig.extendedConfigPath.forEach((extendedConfigPath) => applyExtendedConfig(result, extendedConfigPath));
41365
41480
  }
41366
- if (!ownConfig.raw.include && result.include)
41481
+ if (result.include)
41367
41482
  ownConfig.raw.include = result.include;
41368
- if (!ownConfig.raw.exclude && result.exclude)
41483
+ if (result.exclude)
41369
41484
  ownConfig.raw.exclude = result.exclude;
41370
- if (!ownConfig.raw.files && result.files)
41485
+ if (result.files)
41371
41486
  ownConfig.raw.files = result.files;
41372
41487
  if (ownConfig.raw.compileOnSave === void 0 && result.compileOnSave)
41373
41488
  ownConfig.raw.compileOnSave = result.compileOnSave;
@@ -41383,8 +41498,10 @@ function parseConfig(json, sourceFile, host, basePath, configFileName, resolutio
41383
41498
  const extendsRaw = extendedConfig.raw;
41384
41499
  let relativeDifference;
41385
41500
  const setPropertyInResultIfNotUndefined = (propertyName) => {
41501
+ if (ownConfig.raw[propertyName])
41502
+ return;
41386
41503
  if (extendsRaw[propertyName]) {
41387
- result[propertyName] = map(extendsRaw[propertyName], (path) => isRootedDiskPath(path) ? path : combinePaths(
41504
+ result[propertyName] = map(extendsRaw[propertyName], (path) => startsWithConfigDirTemplate(path) || isRootedDiskPath(path) ? path : combinePaths(
41388
41505
  relativeDifference || (relativeDifference = convertToRelativePath(getDirectoryPath(extendedConfigPath), basePath, createGetCanonicalFileName(host.useCaseSensitiveFileNames))),
41389
41506
  path
41390
41507
  ));
@@ -41662,7 +41779,8 @@ function convertJsonOption(opt, value, basePath, errors, propertyAssignment, val
41662
41779
  }
41663
41780
  function normalizeNonListOptionValue(option, basePath, value) {
41664
41781
  if (option.isFilePath) {
41665
- value = getNormalizedAbsolutePath(value, basePath);
41782
+ value = normalizeSlashes(value);
41783
+ value = !startsWithConfigDirTemplate(value) ? getNormalizedAbsolutePath(value, basePath) : value;
41666
41784
  if (value === "") {
41667
41785
  value = ".";
41668
41786
  }
@@ -49707,7 +49825,6 @@ function createTypeChecker(host) {
49707
49825
  };
49708
49826
  var amalgamatedDuplicates;
49709
49827
  var reverseMappedCache = /* @__PURE__ */ new Map();
49710
- var homomorphicMappedTypeInferenceStack = [];
49711
49828
  var ambientModulesCache;
49712
49829
  var patternAmbientModules;
49713
49830
  var patternAmbientModuleAugmentations;
@@ -49808,6 +49925,9 @@ function createTypeChecker(host) {
49808
49925
  var potentialReflectCollisions = [];
49809
49926
  var potentialUnusedRenamedBindingElementsInTypes = [];
49810
49927
  var awaitedTypeStack = [];
49928
+ var reverseMappedSourceStack = [];
49929
+ var reverseMappedTargetStack = [];
49930
+ var reverseExpandingFlags = 0 /* None */;
49811
49931
  var diagnostics = createDiagnosticCollection();
49812
49932
  var suggestionDiagnostics = createDiagnosticCollection();
49813
49933
  var typeofType = createTypeofType();
@@ -57891,7 +58011,7 @@ function createTypeChecker(host) {
57891
58011
  result.aliasTypeArguments = length(args) ? args : void 0;
57892
58012
  }
57893
58013
  }
57894
- result.objectFlags |= getObjectFlags(type) & 4096 /* JSLiteral */;
58014
+ result.objectFlags |= getPropagatingFlagsOfTypes([type]) | getObjectFlags(type) & (4096 /* JSLiteral */ | 16384 /* ArrayLiteral */ | 128 /* ObjectLiteral */);
57895
58015
  if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) {
57896
58016
  result.objectFlags |= 16777216 /* IsClassInstanceClone */;
57897
58017
  }
@@ -59837,7 +59957,7 @@ function createTypeChecker(host) {
59837
59957
  const modifiers = getMappedTypeModifiers(type.mappedType);
59838
59958
  const readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true;
59839
59959
  const optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */;
59840
- const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : emptyArray;
59960
+ const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType) || unknownType, readonlyMask && indexInfo.isReadonly)] : emptyArray;
59841
59961
  const members = createSymbolTable();
59842
59962
  const limitedConstraint = getLimitedConstraint(type);
59843
59963
  for (const prop of getPropertiesOfType(type.source)) {
@@ -69657,13 +69777,7 @@ function createTypeChecker(host) {
69657
69777
  if (reverseMappedCache.has(cacheKey)) {
69658
69778
  return reverseMappedCache.get(cacheKey);
69659
69779
  }
69660
- const recursionKey = source.id + "," + (target.target || target).id;
69661
- if (contains(homomorphicMappedTypeInferenceStack, recursionKey)) {
69662
- return void 0;
69663
- }
69664
- homomorphicMappedTypeInferenceStack.push(recursionKey);
69665
69780
  const type = createReverseMappedType(source, target, constraint);
69666
- homomorphicMappedTypeInferenceStack.pop();
69667
69781
  reverseMappedCache.set(cacheKey, type);
69668
69782
  return type;
69669
69783
  }
@@ -69675,10 +69789,17 @@ function createTypeChecker(host) {
69675
69789
  return void 0;
69676
69790
  }
69677
69791
  if (isArrayType(source)) {
69678
- return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source));
69792
+ const elementType = inferReverseMappedType(getTypeArguments(source)[0], target, constraint);
69793
+ if (!elementType) {
69794
+ return void 0;
69795
+ }
69796
+ return createArrayType(elementType, isReadonlyArrayType(source));
69679
69797
  }
69680
69798
  if (isTupleType(source)) {
69681
69799
  const elementTypes = map(getElementTypes(source), (t) => inferReverseMappedType(t, target, constraint));
69800
+ if (!every(elementTypes, (t) => !!t)) {
69801
+ return void 0;
69802
+ }
69682
69803
  const elementFlags = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? sameMap(source.target.elementFlags, (f) => f & 2 /* Optional */ ? 1 /* Required */ : f) : source.target.elementFlags;
69683
69804
  return createTupleType(elementTypes, elementFlags, source.target.readonly, source.target.labeledElementDeclarations);
69684
69805
  }
@@ -69695,17 +69816,39 @@ function createTypeChecker(host) {
69695
69816
  function getTypeOfReverseMappedSymbol(symbol) {
69696
69817
  const links = getSymbolLinks(symbol);
69697
69818
  if (!links.type) {
69698
- links.type = inferReverseMappedType(symbol.links.propertyType, symbol.links.mappedType, symbol.links.constraintType);
69819
+ links.type = inferReverseMappedType(symbol.links.propertyType, symbol.links.mappedType, symbol.links.constraintType) || unknownType;
69699
69820
  }
69700
69821
  return links.type;
69701
69822
  }
69702
- function inferReverseMappedType(sourceType, target, constraint) {
69823
+ function inferReverseMappedTypeWorker(sourceType, target, constraint) {
69703
69824
  const typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target));
69704
69825
  const templateType = getTemplateTypeFromMappedType(target);
69705
69826
  const inference = createInferenceInfo(typeParameter);
69706
69827
  inferTypes([inference], sourceType, templateType);
69707
69828
  return getTypeFromInference(inference) || unknownType;
69708
69829
  }
69830
+ function inferReverseMappedType(source, target, constraint) {
69831
+ const cacheKey = source.id + "," + target.id + "," + constraint.id;
69832
+ if (reverseMappedCache.has(cacheKey)) {
69833
+ return reverseMappedCache.get(cacheKey) || unknownType;
69834
+ }
69835
+ reverseMappedSourceStack.push(source);
69836
+ reverseMappedTargetStack.push(target);
69837
+ const saveExpandingFlags = reverseExpandingFlags;
69838
+ if (isDeeplyNestedType(source, reverseMappedSourceStack, reverseMappedSourceStack.length, 2))
69839
+ reverseExpandingFlags |= 1 /* Source */;
69840
+ if (isDeeplyNestedType(target, reverseMappedTargetStack, reverseMappedTargetStack.length, 2))
69841
+ reverseExpandingFlags |= 2 /* Target */;
69842
+ let type;
69843
+ if (reverseExpandingFlags !== 3 /* Both */) {
69844
+ type = inferReverseMappedTypeWorker(source, target, constraint);
69845
+ }
69846
+ reverseMappedSourceStack.pop();
69847
+ reverseMappedTargetStack.pop();
69848
+ reverseExpandingFlags = saveExpandingFlags;
69849
+ reverseMappedCache.set(cacheKey, type);
69850
+ return type;
69851
+ }
69709
69852
  function* getUnmatchedProperties(source, target, requireOptionalProperties, matchDiscriminantProperties) {
69710
69853
  const properties = getPropertiesOfType(target);
69711
69854
  for (const targetProp of properties) {
@@ -128608,7 +128751,8 @@ function getMatchedFileSpec(program, fileName) {
128608
128751
  return void 0;
128609
128752
  const filePath = program.getCanonicalFileName(fileName);
128610
128753
  const basePath = getDirectoryPath(getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory()));
128611
- return find(configFile.configFileSpecs.validatedFilesSpec, (fileSpec) => program.getCanonicalFileName(getNormalizedAbsolutePath(fileSpec, basePath)) === filePath);
128754
+ const index = findIndex(configFile.configFileSpecs.validatedFilesSpec, (fileSpec) => program.getCanonicalFileName(getNormalizedAbsolutePath(fileSpec, basePath)) === filePath);
128755
+ return index !== -1 ? configFile.configFileSpecs.validatedFilesSpecBeforeSubstitution[index] : void 0;
128612
128756
  }
128613
128757
  function getMatchedIncludeSpec(program, fileName) {
128614
128758
  var _a, _b;
@@ -128620,12 +128764,13 @@ function getMatchedIncludeSpec(program, fileName) {
128620
128764
  const isJsonFile = fileExtensionIs(fileName, ".json" /* Json */);
128621
128765
  const basePath = getDirectoryPath(getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory()));
128622
128766
  const useCaseSensitiveFileNames2 = program.useCaseSensitiveFileNames();
128623
- return find((_b = configFile == null ? void 0 : configFile.configFileSpecs) == null ? void 0 : _b.validatedIncludeSpecs, (includeSpec) => {
128767
+ const index = findIndex((_b = configFile == null ? void 0 : configFile.configFileSpecs) == null ? void 0 : _b.validatedIncludeSpecs, (includeSpec) => {
128624
128768
  if (isJsonFile && !endsWith(includeSpec, ".json" /* Json */))
128625
128769
  return false;
128626
128770
  const pattern = getPatternFromSpec(includeSpec, basePath, "files");
128627
128771
  return !!pattern && getRegexFromPattern(`(${pattern})$`, useCaseSensitiveFileNames2).test(fileName);
128628
128772
  });
128773
+ return index !== -1 ? configFile.configFileSpecs.validatedIncludeSpecsBeforeSubstitution[index] : void 0;
128629
128774
  }
128630
128775
  function fileIncludeReasonToDiagnostics(program, reason, fileNameConvertor) {
128631
128776
  var _a, _b;
@@ -176028,6 +176173,8 @@ __export(ts_exports2, {
176028
176173
  computedOptions: () => computedOptions,
176029
176174
  concatenate: () => concatenate,
176030
176175
  concatenateDiagnosticMessageChains: () => concatenateDiagnosticMessageChains,
176176
+ configDirTemplateSubstitutionOptions: () => configDirTemplateSubstitutionOptions,
176177
+ configDirTemplateSubstitutionWatchOptions: () => configDirTemplateSubstitutionWatchOptions,
176031
176178
  consumesNodeCoreModules: () => consumesNodeCoreModules,
176032
176179
  contains: () => contains,
176033
176180
  containsIgnoredPath: () => containsIgnoredPath,
@@ -176798,6 +176945,7 @@ __export(ts_exports2, {
176798
176945
  groupBy: () => groupBy,
176799
176946
  guessIndentation: () => guessIndentation,
176800
176947
  handleNoEmitOptions: () => handleNoEmitOptions,
176948
+ handleWatchOptionsConfigDirTemplateSubstitution: () => handleWatchOptionsConfigDirTemplateSubstitution,
176801
176949
  hasAbstractModifier: () => hasAbstractModifier,
176802
176950
  hasAccessorModifier: () => hasAccessorModifier,
176803
176951
  hasAmbientModifier: () => hasAmbientModifier,
@@ -178141,37 +178289,6 @@ function buildOverload(name) {
178141
178289
  };
178142
178290
  }
178143
178291
 
178144
- // src/deprecatedCompat/5.0/identifierProperties.ts
178145
- addObjectAllocatorPatcher((objectAllocator2) => {
178146
- const Identifier78 = objectAllocator2.getIdentifierConstructor();
178147
- if (!hasProperty(Identifier78.prototype, "originalKeywordKind")) {
178148
- Object.defineProperty(Identifier78.prototype, "originalKeywordKind", {
178149
- get: deprecate(function() {
178150
- return identifierToKeywordKind(this);
178151
- }, {
178152
- name: "originalKeywordKind",
178153
- since: "5.0",
178154
- warnAfter: "5.1",
178155
- errorAfter: "5.2",
178156
- message: "Use 'identifierToKeywordKind(identifier)' instead."
178157
- })
178158
- });
178159
- }
178160
- if (!hasProperty(Identifier78.prototype, "isInJSDocNamespace")) {
178161
- Object.defineProperty(Identifier78.prototype, "isInJSDocNamespace", {
178162
- get: deprecate(function() {
178163
- return this.flags & 4096 /* IdentifierIsInJSDocNamespace */ ? true : void 0;
178164
- }, {
178165
- name: "isInJSDocNamespace",
178166
- since: "5.0",
178167
- warnAfter: "5.1",
178168
- errorAfter: "5.2",
178169
- message: "Use '.parent' or the surrounding context to determine this instead."
178170
- })
178171
- });
178172
- }
178173
- });
178174
-
178175
178292
  // src/server/_namespaces/ts.server.ts
178176
178293
  var ts_server_exports3 = {};
178177
178294
  __export(ts_server_exports3, {
@@ -183023,7 +183140,7 @@ var _ProjectService = class _ProjectService {
183023
183140
  });
183024
183141
  },
183025
183142
  flags,
183026
- this.getWatchOptionsFromProjectWatchOptions(config.parsedCommandLine.watchOptions),
183143
+ this.getWatchOptionsFromProjectWatchOptions(config.parsedCommandLine.watchOptions, getDirectoryPath(configFileName)),
183027
183144
  WatchType.WildcardDirectory,
183028
183145
  configFileName
183029
183146
  );
@@ -183313,7 +183430,7 @@ var _ProjectService = class _ProjectService {
183313
183430
  configFileName,
183314
183431
  (_fileName, eventKind) => this.onConfigFileChanged(canonicalConfigFilePath, eventKind),
183315
183432
  2e3 /* High */,
183316
- this.getWatchOptionsFromProjectWatchOptions((_b = (_a = configFileExistenceInfo == null ? void 0 : configFileExistenceInfo.config) == null ? void 0 : _a.parsedCommandLine) == null ? void 0 : _b.watchOptions),
183433
+ this.getWatchOptionsFromProjectWatchOptions((_b = (_a = configFileExistenceInfo == null ? void 0 : configFileExistenceInfo.config) == null ? void 0 : _a.parsedCommandLine) == null ? void 0 : _b.watchOptions, getDirectoryPath(configFileName)),
183317
183434
  WatchType.ConfigFile,
183318
183435
  forProject
183319
183436
  );
@@ -183742,15 +183859,16 @@ var _ProjectService = class _ProjectService {
183742
183859
  const configFileErrors = configFile.parseDiagnostics;
183743
183860
  if (!isString(configFileContent))
183744
183861
  configFileErrors.push(configFileContent);
183862
+ const configDir = getDirectoryPath(configFilename);
183745
183863
  const parsedCommandLine = parseJsonSourceFileConfigFileContent(
183746
183864
  configFile,
183747
183865
  cachedDirectoryStructureHost,
183748
- getDirectoryPath(configFilename),
183866
+ configDir,
183749
183867
  /*existingOptions*/
183750
- {},
183868
+ void 0,
183751
183869
  configFilename,
183752
183870
  /*resolutionStack*/
183753
- [],
183871
+ void 0,
183754
183872
  this.hostConfiguration.extraFileExtensions,
183755
183873
  this.extendedConfigCache
183756
183874
  );
@@ -183780,10 +183898,11 @@ var _ProjectService = class _ProjectService {
183780
183898
  // Old options
183781
183899
  this.getWatchOptionsFromProjectWatchOptions(
183782
183900
  /*projectOptions*/
183783
- void 0
183901
+ void 0,
183902
+ configDir
183784
183903
  ),
183785
183904
  // New options
183786
- this.getWatchOptionsFromProjectWatchOptions(parsedCommandLine.watchOptions)
183905
+ this.getWatchOptionsFromProjectWatchOptions(parsedCommandLine.watchOptions, configDir)
183787
183906
  )) {
183788
183907
  (_c = configFileExistenceInfo.watcher) == null ? void 0 : _c.close();
183789
183908
  configFileExistenceInfo.watcher = void 0;
@@ -184551,18 +184670,25 @@ Dynamic files must always be opened with service's current directory or service
184551
184670
  this.logger.info("Host file extension mappings updated");
184552
184671
  }
184553
184672
  if (args.watchOptions) {
184554
- this.hostConfiguration.watchOptions = (_a = convertWatchOptions(args.watchOptions)) == null ? void 0 : _a.watchOptions;
184673
+ const watchOptions = (_a = convertWatchOptions(args.watchOptions)) == null ? void 0 : _a.watchOptions;
184674
+ const substitution = handleWatchOptionsConfigDirTemplateSubstitution(watchOptions, this.currentDirectory);
184675
+ this.hostConfiguration.watchOptions = substitution;
184676
+ this.hostConfiguration.beforeSubstitution = substitution === watchOptions ? void 0 : watchOptions;
184555
184677
  this.logger.info(`Host watch options changed to ${JSON.stringify(this.hostConfiguration.watchOptions)}, it will be take effect for next watches.`);
184556
184678
  }
184557
184679
  }
184558
184680
  }
184559
184681
  /** @internal */
184560
184682
  getWatchOptions(project) {
184561
- return this.getWatchOptionsFromProjectWatchOptions(project.getWatchOptions());
184683
+ return this.getWatchOptionsFromProjectWatchOptions(project.getWatchOptions(), project.getCurrentDirectory());
184562
184684
  }
184563
184685
  /** @internal */
184564
- getWatchOptionsFromProjectWatchOptions(projectOptions) {
184565
- return projectOptions && this.hostConfiguration.watchOptions ? { ...this.hostConfiguration.watchOptions, ...projectOptions } : projectOptions || this.hostConfiguration.watchOptions;
184686
+ getWatchOptionsFromProjectWatchOptions(projectOptions, basePath) {
184687
+ const hostWatchOptions = !this.hostConfiguration.beforeSubstitution ? this.hostConfiguration.watchOptions : handleWatchOptionsConfigDirTemplateSubstitution(
184688
+ this.hostConfiguration.beforeSubstitution,
184689
+ basePath
184690
+ );
184691
+ return projectOptions && hostWatchOptions ? { ...hostWatchOptions, ...projectOptions } : projectOptions || hostWatchOptions;
184566
184692
  }
184567
184693
  closeLog() {
184568
184694
  this.logger.close();
@@ -184943,7 +185069,12 @@ Dynamic files must always be opened with service's current directory or service
184943
185069
  return result;
184944
185070
  }
184945
185071
  removeOrphanConfiguredProjects(toRetainConfiguredProjects) {
184946
- const toRemoveConfiguredProjects = new Map(this.configuredProjects);
185072
+ const orphanConfiguredProjects = this.getOrphanConfiguredProjects(toRetainConfiguredProjects);
185073
+ orphanConfiguredProjects.forEach((project) => this.removeProject(project));
185074
+ }
185075
+ /** @internal */
185076
+ getOrphanConfiguredProjects(toRetainConfiguredProjects) {
185077
+ const toRemoveConfiguredProjects = new Set(this.configuredProjects.values());
184947
185078
  const markOriginalProjectsAsUsed = (project) => {
184948
185079
  if (project.originalConfiguredProjects && (isConfiguredProject(project) || !project.isOrphan())) {
184949
185080
  project.originalConfiguredProjects.forEach(
@@ -184964,7 +185095,7 @@ Dynamic files must always be opened with service's current directory or service
184964
185095
  this.inferredProjects.forEach(markOriginalProjectsAsUsed);
184965
185096
  this.externalProjects.forEach(markOriginalProjectsAsUsed);
184966
185097
  this.configuredProjects.forEach((project) => {
184967
- if (!toRemoveConfiguredProjects.has(project.canonicalConfigFilePath))
185098
+ if (!toRemoveConfiguredProjects.has(project))
184968
185099
  return;
184969
185100
  if (project.hasOpenRef()) {
184970
185101
  retainConfiguredProject(project);
@@ -184972,12 +185103,12 @@ Dynamic files must always be opened with service's current directory or service
184972
185103
  retainConfiguredProject(project);
184973
185104
  }
184974
185105
  });
184975
- toRemoveConfiguredProjects.forEach((project) => this.removeProject(project));
185106
+ return toRemoveConfiguredProjects;
184976
185107
  function isRetained(project) {
184977
- return !toRemoveConfiguredProjects.has(project.canonicalConfigFilePath) || project.hasOpenRef();
185108
+ return !toRemoveConfiguredProjects.has(project) || project.hasOpenRef();
184978
185109
  }
184979
185110
  function retainConfiguredProject(project) {
184980
- if (toRemoveConfiguredProjects.delete(project.canonicalConfigFilePath)) {
185111
+ if (toRemoveConfiguredProjects.delete(project)) {
184981
185112
  markOriginalProjectsAsUsed(project);
184982
185113
  forEachReferencedProject(project, retainConfiguredProject);
184983
185114
  }
@@ -190410,6 +190541,8 @@ if (typeof console !== "undefined") {
190410
190541
  computedOptions,
190411
190542
  concatenate,
190412
190543
  concatenateDiagnosticMessageChains,
190544
+ configDirTemplateSubstitutionOptions,
190545
+ configDirTemplateSubstitutionWatchOptions,
190413
190546
  consumesNodeCoreModules,
190414
190547
  contains,
190415
190548
  containsIgnoredPath,
@@ -191180,6 +191313,7 @@ if (typeof console !== "undefined") {
191180
191313
  groupBy,
191181
191314
  guessIndentation,
191182
191315
  handleNoEmitOptions,
191316
+ handleWatchOptionsConfigDirTemplateSubstitution,
191183
191317
  hasAbstractModifier,
191184
191318
  hasAccessorModifier,
191185
191319
  hasAmbientModifier,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.5.0-dev.20240416",
5
+ "version": "5.5.0-dev.20240418",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -111,5 +111,5 @@
111
111
  "node": "20.1.0",
112
112
  "npm": "8.19.4"
113
113
  },
114
- "gitHead": "ce213148ec562296ac7da215ca179043632c119c"
114
+ "gitHead": "72f413cea0fa8b98948f9608bb7a113070c7733f"
115
115
  }