typescript 5.4.2 → 5.4.5

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/typescript.js CHANGED
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.4";
38
- version = "5.4.2";
38
+ version = "5.4.5";
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -5423,14 +5423,17 @@ ${lanes.join("\n")}
5423
5423
  pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === 250 /* Low */ ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingInterval === 250 /* Low */ ? "pollLowPollingIntervalQueue" : "pollPollingIntervalQueue", pollingIntervalQueue(pollingInterval));
5424
5424
  }
5425
5425
  }
5426
- function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames2) {
5426
+ function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames2, getModifiedTime3, fsWatchWithTimestamp) {
5427
5427
  const fileWatcherCallbacks = createMultiMap();
5428
+ const fileTimestamps = fsWatchWithTimestamp ? /* @__PURE__ */ new Map() : void 0;
5428
5429
  const dirWatchers = /* @__PURE__ */ new Map();
5429
5430
  const toCanonicalName = createGetCanonicalFileName(useCaseSensitiveFileNames2);
5430
5431
  return nonPollingWatchFile;
5431
5432
  function nonPollingWatchFile(fileName, callback, _pollingInterval, fallbackOptions) {
5432
5433
  const filePath = toCanonicalName(fileName);
5433
- fileWatcherCallbacks.add(filePath, callback);
5434
+ if (fileWatcherCallbacks.add(filePath, callback).length === 1 && fileTimestamps) {
5435
+ fileTimestamps.set(filePath, getModifiedTime3(fileName) || missingFileModifiedTime);
5436
+ }
5434
5437
  const dirPath = getDirectoryPath(filePath) || ".";
5435
5438
  const watcher = dirWatchers.get(dirPath) || createDirectoryWatcher(getDirectoryPath(fileName) || ".", dirPath, fallbackOptions);
5436
5439
  watcher.referenceCount++;
@@ -5450,14 +5453,31 @@ ${lanes.join("\n")}
5450
5453
  const watcher = fsWatch(
5451
5454
  dirName,
5452
5455
  1 /* Directory */,
5453
- (_eventName, relativeFileName, modifiedTime) => {
5456
+ (eventName, relativeFileName) => {
5454
5457
  if (!isString(relativeFileName))
5455
5458
  return;
5456
5459
  const fileName = getNormalizedAbsolutePath(relativeFileName, dirName);
5457
- const callbacks = fileName && fileWatcherCallbacks.get(toCanonicalName(fileName));
5460
+ const filePath = toCanonicalName(fileName);
5461
+ const callbacks = fileName && fileWatcherCallbacks.get(filePath);
5458
5462
  if (callbacks) {
5463
+ let currentModifiedTime;
5464
+ let eventKind = 1 /* Changed */;
5465
+ if (fileTimestamps) {
5466
+ const existingTime = fileTimestamps.get(filePath);
5467
+ if (eventName === "change") {
5468
+ currentModifiedTime = getModifiedTime3(fileName) || missingFileModifiedTime;
5469
+ if (currentModifiedTime.getTime() === existingTime.getTime())
5470
+ return;
5471
+ }
5472
+ currentModifiedTime || (currentModifiedTime = getModifiedTime3(fileName) || missingFileModifiedTime);
5473
+ fileTimestamps.set(filePath, currentModifiedTime);
5474
+ if (existingTime === missingFileModifiedTime)
5475
+ eventKind = 0 /* Created */;
5476
+ else if (currentModifiedTime === missingFileModifiedTime)
5477
+ eventKind = 2 /* Deleted */;
5478
+ }
5459
5479
  for (const fileCallback of callbacks) {
5460
- fileCallback(fileName, 1 /* Changed */, modifiedTime);
5480
+ fileCallback(fileName, eventKind, currentModifiedTime);
5461
5481
  }
5462
5482
  }
5463
5483
  },
@@ -5849,7 +5869,7 @@ ${lanes.join("\n")}
5849
5869
  );
5850
5870
  case 5 /* UseFsEventsOnParentDirectory */:
5851
5871
  if (!nonPollingWatchFile) {
5852
- nonPollingWatchFile = createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames2);
5872
+ nonPollingWatchFile = createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames2, getModifiedTime3, fsWatchWithTimestamp);
5853
5873
  }
5854
5874
  return nonPollingWatchFile(fileName, callback, pollingInterval, getFallbackOptions(options));
5855
5875
  default:
@@ -6024,7 +6044,7 @@ ${lanes.join("\n")}
6024
6044
  return watchPresentFileSystemEntryWithFsWatchFile();
6025
6045
  }
6026
6046
  try {
6027
- const presentWatcher = (!fsWatchWithTimestamp ? fsWatchWorker : fsWatchWorkerHandlingTimestamp)(
6047
+ const presentWatcher = (entryKind === 1 /* Directory */ || !fsWatchWithTimestamp ? fsWatchWorker : fsWatchWorkerHandlingTimestamp)(
6028
6048
  fileOrDirectory,
6029
6049
  recursive,
6030
6050
  inodeWatching ? callbackChangingToMissingFileSystemEntry : callback
@@ -45450,13 +45470,21 @@ ${lanes.join("\n")}
45450
45470
  }
45451
45471
  const nearestTargetPackageJson = getNearestAncestorDirectoryWithPackageJson(host, getDirectoryPath(modulePath));
45452
45472
  const nearestSourcePackageJson = getNearestAncestorDirectoryWithPackageJson(host, sourceDirectory);
45453
- if (nearestSourcePackageJson !== nearestTargetPackageJson) {
45473
+ const ignoreCase = !hostUsesCaseSensitiveFileNames(host);
45474
+ if (!packageJsonPathsAreEqual(nearestTargetPackageJson, nearestSourcePackageJson, ignoreCase)) {
45454
45475
  return maybeNonRelative;
45455
45476
  }
45456
45477
  return relativePath;
45457
45478
  }
45458
45479
  return isPathRelativeToParent(maybeNonRelative) || countPathComponents(relativePath) < countPathComponents(maybeNonRelative) ? relativePath : maybeNonRelative;
45459
45480
  }
45481
+ function packageJsonPathsAreEqual(a, b, ignoreCase) {
45482
+ if (a === b)
45483
+ return true;
45484
+ if (a === void 0 || b === void 0)
45485
+ return false;
45486
+ return comparePaths(a, b, ignoreCase) === 0 /* EqualTo */;
45487
+ }
45460
45488
  function countPathComponents(path) {
45461
45489
  let count = 0;
45462
45490
  for (let i = startsWith(path, "./") ? 2 : 0; i < path.length; i++) {
@@ -50016,13 +50044,6 @@ ${lanes.join("\n")}
50016
50044
  });
50017
50045
  }
50018
50046
  function getSymbolIfSameReference(s1, s2) {
50019
- var _a, _b;
50020
- if (s1.flags & 524288 /* TypeAlias */ && ((_a = s2.declarations) == null ? void 0 : _a.find(isTypeAlias))) {
50021
- s2 = getDeclaredTypeOfTypeAlias(s2).aliasSymbol || s2;
50022
- }
50023
- if (s2.flags & 524288 /* TypeAlias */ && ((_b = s1.declarations) == null ? void 0 : _b.find(isTypeAlias))) {
50024
- s1 = getDeclaredTypeOfTypeAlias(s1).aliasSymbol || s1;
50025
- }
50026
50047
  if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
50027
50048
  return s1;
50028
50049
  }
@@ -50502,15 +50523,19 @@ ${lanes.join("\n")}
50502
50523
  return true;
50503
50524
  }
50504
50525
  }
50505
- function isEntityNameVisible(entityName, enclosingDeclaration) {
50526
+ function getMeaningOfEntityNameReference(entityName) {
50506
50527
  let meaning;
50507
50528
  if (entityName.parent.kind === 186 /* TypeQuery */ || entityName.parent.kind === 233 /* ExpressionWithTypeArguments */ && !isPartOfTypeNode(entityName.parent) || entityName.parent.kind === 167 /* ComputedPropertyName */) {
50508
50529
  meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
50509
- } else if (entityName.kind === 166 /* QualifiedName */ || entityName.kind === 211 /* PropertyAccessExpression */ || entityName.parent.kind === 271 /* ImportEqualsDeclaration */) {
50530
+ } else if (entityName.kind === 166 /* QualifiedName */ || entityName.kind === 211 /* PropertyAccessExpression */ || entityName.parent.kind === 271 /* ImportEqualsDeclaration */ || entityName.parent.kind === 166 /* QualifiedName */ && entityName.parent.left === entityName || entityName.parent.kind === 211 /* PropertyAccessExpression */ && entityName.parent.expression === entityName || entityName.parent.kind === 212 /* ElementAccessExpression */ && entityName.parent.expression === entityName) {
50510
50531
  meaning = 1920 /* Namespace */;
50511
50532
  } else {
50512
50533
  meaning = 788968 /* Type */;
50513
50534
  }
50535
+ return meaning;
50536
+ }
50537
+ function isEntityNameVisible(entityName, enclosingDeclaration) {
50538
+ const meaning = getMeaningOfEntityNameReference(entityName);
50514
50539
  const firstIdentifier = getFirstIdentifier(entityName);
50515
50540
  const symbol = resolveName(
50516
50541
  enclosingDeclaration,
@@ -52571,9 +52596,10 @@ ${lanes.join("\n")}
52571
52596
  introducesError = true;
52572
52597
  return { introducesError, node };
52573
52598
  }
52599
+ const meaning = getMeaningOfEntityNameReference(node);
52574
52600
  const sym = resolveEntityName(
52575
52601
  leftmost,
52576
- -1 /* All */,
52602
+ meaning,
52577
52603
  /*ignoreErrors*/
52578
52604
  true,
52579
52605
  /*dontResolveAlias*/
@@ -52583,13 +52609,13 @@ ${lanes.join("\n")}
52583
52609
  if (isSymbolAccessible(
52584
52610
  sym,
52585
52611
  context.enclosingDeclaration,
52586
- -1 /* All */,
52612
+ meaning,
52587
52613
  /*shouldComputeAliasesToMakeVisible*/
52588
52614
  false
52589
52615
  ).accessibility !== 0 /* Accessible */) {
52590
52616
  introducesError = true;
52591
52617
  } else {
52592
- context.tracker.trackSymbol(sym, context.enclosingDeclaration, -1 /* All */);
52618
+ context.tracker.trackSymbol(sym, context.enclosingDeclaration, meaning);
52593
52619
  includePrivateSymbol == null ? void 0 : includePrivateSymbol(sym);
52594
52620
  }
52595
52621
  if (isIdentifier(node)) {
@@ -57817,16 +57843,17 @@ ${lanes.join("\n")}
57817
57843
  const target = type.target ?? type;
57818
57844
  const typeVariable = getHomomorphicTypeVariable(target);
57819
57845
  if (typeVariable && !target.declaration.nameType) {
57820
- const constraint = getConstraintTypeFromMappedType(type);
57821
- if (constraint.flags & 4194304 /* Index */) {
57822
- const baseConstraint = getBaseConstraintOfType(constraint.type);
57823
- if (baseConstraint && everyType(baseConstraint, isArrayOrTupleType)) {
57824
- return instantiateType(target, prependTypeMapping(typeVariable, baseConstraint, type.mapper));
57825
- }
57846
+ const modifiersType = getModifiersTypeFromMappedType(type);
57847
+ const baseConstraint = isGenericMappedType(modifiersType) ? getApparentTypeOfMappedType(modifiersType) : getBaseConstraintOfType(modifiersType);
57848
+ if (baseConstraint && everyType(baseConstraint, (t) => isArrayOrTupleType(t) || isArrayOrTupleOrIntersection(t))) {
57849
+ return instantiateType(target, prependTypeMapping(typeVariable, baseConstraint, type.mapper));
57826
57850
  }
57827
57851
  }
57828
57852
  return type;
57829
57853
  }
57854
+ function isArrayOrTupleOrIntersection(type) {
57855
+ return !!(type.flags & 2097152 /* Intersection */) && every(type.types, isArrayOrTupleType);
57856
+ }
57830
57857
  function isMappedTypeGenericIndexedAccess(type) {
57831
57858
  let objectType;
57832
57859
  return !!(type.flags & 8388608 /* IndexedAccess */ && getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType);
@@ -57980,13 +58007,13 @@ ${lanes.join("\n")}
57980
58007
  }
57981
58008
  function getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment) {
57982
58009
  var _a, _b, _c;
57983
- let property = ((_a = type.propertyCacheWithoutObjectFunctionPropertyAugment) == null ? void 0 : _a.get(name)) || !skipObjectFunctionPropertyAugment ? (_b = type.propertyCache) == null ? void 0 : _b.get(name) : void 0;
58010
+ let property = skipObjectFunctionPropertyAugment ? (_a = type.propertyCacheWithoutObjectFunctionPropertyAugment) == null ? void 0 : _a.get(name) : (_b = type.propertyCache) == null ? void 0 : _b.get(name);
57984
58011
  if (!property) {
57985
58012
  property = createUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
57986
58013
  if (property) {
57987
58014
  const properties = skipObjectFunctionPropertyAugment ? type.propertyCacheWithoutObjectFunctionPropertyAugment || (type.propertyCacheWithoutObjectFunctionPropertyAugment = createSymbolTable()) : type.propertyCache || (type.propertyCache = createSymbolTable());
57988
58015
  properties.set(name, property);
57989
- if (skipObjectFunctionPropertyAugment && !((_c = type.propertyCache) == null ? void 0 : _c.get(name))) {
58016
+ if (skipObjectFunctionPropertyAugment && !(getCheckFlags(property) & 48 /* Partial */) && !((_c = type.propertyCache) == null ? void 0 : _c.get(name))) {
57990
58017
  const properties2 = type.propertyCache || (type.propertyCache = createSymbolTable());
57991
58018
  properties2.set(name, property);
57992
58019
  }
@@ -60465,7 +60492,7 @@ ${lanes.join("\n")}
60465
60492
  const typeVarIndex = typeSet[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
60466
60493
  const typeVariable = typeSet[typeVarIndex];
60467
60494
  const primitiveType = typeSet[1 - typeVarIndex];
60468
- if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) || includes & 16777216 /* IncludesEmptyObject */)) {
60495
+ if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) && !isGenericStringLikeType(primitiveType) || includes & 16777216 /* IncludesEmptyObject */)) {
60469
60496
  const constraint = getBaseConstraintOfType(typeVariable);
60470
60497
  if (constraint && everyType(constraint, (t) => !!(t.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */)) || isEmptyAnonymousObjectType(t))) {
60471
60498
  if (isTypeStrictSubtypeOf(constraint, primitiveType)) {
@@ -60493,6 +60520,9 @@ ${lanes.join("\n")}
60493
60520
  } else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
60494
60521
  removeFromEach(typeSet, 65536 /* Null */);
60495
60522
  result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
60523
+ } else if (typeSet.length >= 4) {
60524
+ const middle = Math.floor(typeSet.length / 2);
60525
+ result = getIntersectionType([getIntersectionType(typeSet.slice(0, middle)), getIntersectionType(typeSet.slice(middle))], aliasSymbol, aliasTypeArguments);
60496
60526
  } else {
60497
60527
  if (!checkCrossProductUnion(typeSet)) {
60498
60528
  return errorType;
@@ -61073,6 +61103,9 @@ ${lanes.join("\n")}
61073
61103
  function isPatternLiteralType(type) {
61074
61104
  return !!(type.flags & 134217728 /* TemplateLiteral */) && every(type.types, isPatternLiteralPlaceholderType) || !!(type.flags & 268435456 /* StringMapping */) && isPatternLiteralPlaceholderType(type.type);
61075
61105
  }
61106
+ function isGenericStringLikeType(type) {
61107
+ return !!(type.flags & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) && !isPatternLiteralType(type);
61108
+ }
61076
61109
  function isGenericType(type) {
61077
61110
  return !!getGenericObjectFlags(type);
61078
61111
  }
@@ -61095,7 +61128,7 @@ ${lanes.join("\n")}
61095
61128
  }
61096
61129
  return type.objectFlags & 12582912 /* IsGenericType */;
61097
61130
  }
61098
- return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0);
61131
+ return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */) || isGenericStringLikeType(type) ? 8388608 /* IsGenericIndexType */ : 0);
61099
61132
  }
61100
61133
  function getSimplifiedType(type, writing) {
61101
61134
  return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : type;
@@ -62194,29 +62227,28 @@ ${lanes.join("\n")}
62194
62227
  if (typeVariable) {
62195
62228
  const mappedTypeVariable = instantiateType(typeVariable, mapper);
62196
62229
  if (typeVariable !== mappedTypeVariable) {
62197
- return mapTypeWithAlias(
62198
- getReducedType(mappedTypeVariable),
62199
- (t) => {
62200
- if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
62201
- if (!type.declaration.nameType) {
62202
- let constraint;
62203
- if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
62204
- return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
62205
- }
62206
- if (isTupleType(t)) {
62207
- return instantiateMappedTupleType(t, type, typeVariable, mapper);
62208
- }
62209
- }
62210
- return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
62211
- }
62212
- return t;
62213
- },
62214
- aliasSymbol,
62215
- aliasTypeArguments
62216
- );
62230
+ return mapTypeWithAlias(getReducedType(mappedTypeVariable), instantiateConstituent, aliasSymbol, aliasTypeArguments);
62217
62231
  }
62218
62232
  }
62219
62233
  return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments);
62234
+ function instantiateConstituent(t) {
62235
+ if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
62236
+ if (!type.declaration.nameType) {
62237
+ let constraint;
62238
+ if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
62239
+ return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
62240
+ }
62241
+ if (isTupleType(t)) {
62242
+ return instantiateMappedTupleType(t, type, typeVariable, mapper);
62243
+ }
62244
+ if (isArrayOrTupleOrIntersection(t)) {
62245
+ return getIntersectionType(map(t.types, instantiateConstituent));
62246
+ }
62247
+ }
62248
+ return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
62249
+ }
62250
+ return t;
62251
+ }
62220
62252
  }
62221
62253
  function getModifiedReadonlyState(state, modifiers) {
62222
62254
  return modifiers & 1 /* IncludeReadonly */ ? true : modifiers & 2 /* ExcludeReadonly */ ? false : state;
@@ -68143,7 +68175,7 @@ ${lanes.join("\n")}
68143
68175
  function hasMatchingArgument(expression, reference) {
68144
68176
  if (expression.arguments) {
68145
68177
  for (const argument of expression.arguments) {
68146
- if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference) || getCandidateDiscriminantPropertyAccess(argument, reference)) {
68178
+ if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference)) {
68147
68179
  return true;
68148
68180
  }
68149
68181
  }
@@ -68153,36 +68185,6 @@ ${lanes.join("\n")}
68153
68185
  }
68154
68186
  return false;
68155
68187
  }
68156
- function getCandidateDiscriminantPropertyAccess(expr, reference) {
68157
- if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) {
68158
- if (isIdentifier(expr)) {
68159
- const symbol = getResolvedSymbol(expr);
68160
- const declaration = symbol.valueDeclaration;
68161
- if (declaration && (isBindingElement(declaration) || isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
68162
- return declaration;
68163
- }
68164
- }
68165
- } else if (isAccessExpression(expr)) {
68166
- if (isMatchingReference(reference, expr.expression)) {
68167
- return expr;
68168
- }
68169
- } else if (isIdentifier(expr)) {
68170
- const symbol = getResolvedSymbol(expr);
68171
- if (isConstantVariable(symbol)) {
68172
- const declaration = symbol.valueDeclaration;
68173
- if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && isMatchingReference(reference, declaration.initializer.expression)) {
68174
- return declaration.initializer;
68175
- }
68176
- if (isBindingElement(declaration) && !declaration.initializer) {
68177
- const parent2 = declaration.parent.parent;
68178
- if (isVariableDeclaration(parent2) && !parent2.type && parent2.initializer && (isIdentifier(parent2.initializer) || isAccessExpression(parent2.initializer)) && isMatchingReference(reference, parent2.initializer)) {
68179
- return declaration;
68180
- }
68181
- }
68182
- }
68183
- }
68184
- return void 0;
68185
- }
68186
68188
  function getFlowNodeId(flow) {
68187
68189
  if (!flow.id || flow.id < 0) {
68188
68190
  flow.id = nextFlowId;
@@ -69282,9 +69284,39 @@ ${lanes.join("\n")}
69282
69284
  }
69283
69285
  return result;
69284
69286
  }
69287
+ function getCandidateDiscriminantPropertyAccess(expr) {
69288
+ if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) {
69289
+ if (isIdentifier(expr)) {
69290
+ const symbol = getResolvedSymbol(expr);
69291
+ const declaration = symbol.valueDeclaration;
69292
+ if (declaration && (isBindingElement(declaration) || isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
69293
+ return declaration;
69294
+ }
69295
+ }
69296
+ } else if (isAccessExpression(expr)) {
69297
+ if (isMatchingReference(reference, expr.expression)) {
69298
+ return expr;
69299
+ }
69300
+ } else if (isIdentifier(expr)) {
69301
+ const symbol = getResolvedSymbol(expr);
69302
+ if (isConstantVariable(symbol)) {
69303
+ const declaration = symbol.valueDeclaration;
69304
+ if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && isMatchingReference(reference, declaration.initializer.expression)) {
69305
+ return declaration.initializer;
69306
+ }
69307
+ if (isBindingElement(declaration) && !declaration.initializer) {
69308
+ const parent2 = declaration.parent.parent;
69309
+ if (isVariableDeclaration(parent2) && !parent2.type && parent2.initializer && (isIdentifier(parent2.initializer) || isAccessExpression(parent2.initializer)) && isMatchingReference(reference, parent2.initializer)) {
69310
+ return declaration;
69311
+ }
69312
+ }
69313
+ }
69314
+ }
69315
+ return void 0;
69316
+ }
69285
69317
  function getDiscriminantPropertyAccess(expr, computedType) {
69286
69318
  if (declaredType.flags & 1048576 /* Union */ || computedType.flags & 1048576 /* Union */) {
69287
- const access = getCandidateDiscriminantPropertyAccess(expr, reference);
69319
+ const access = getCandidateDiscriminantPropertyAccess(expr);
69288
69320
  if (access) {
69289
69321
  const name = getAccessedPropertyName(access);
69290
69322
  if (name) {
@@ -75005,7 +75037,7 @@ ${lanes.join("\n")}
75005
75037
  }
75006
75038
  return resolveErrorCall(node);
75007
75039
  }
75008
- if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunctionOrConstructor)) {
75040
+ if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
75009
75041
  skippedGenericFunction(node, checkMode);
75010
75042
  return resolvingSignature;
75011
75043
  }
@@ -75015,12 +75047,8 @@ ${lanes.join("\n")}
75015
75047
  }
75016
75048
  return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
75017
75049
  }
75018
- function isGenericFunctionReturningFunctionOrConstructor(signature) {
75019
- if (!signature.typeParameters) {
75020
- return false;
75021
- }
75022
- const returnType = getReturnTypeOfSignature(signature);
75023
- return isFunctionType(returnType) || isConstructorType(returnType);
75050
+ function isGenericFunctionReturningFunction(signature) {
75051
+ return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
75024
75052
  }
75025
75053
  function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
75026
75054
  return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType);
@@ -83177,7 +83205,7 @@ ${lanes.join("\n")}
83177
83205
  error2(member.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums);
83178
83206
  } else {
83179
83207
  const text = getTextOfPropertyName(member.name);
83180
- if (isNumericLiteralName(text)) {
83208
+ if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) {
83181
83209
  error2(member.name, Diagnostics.An_enum_member_cannot_have_a_numeric_name);
83182
83210
  }
83183
83211
  }
@@ -159652,7 +159680,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
159652
159680
  }
159653
159681
  function symbolAppearsToBeTypeOnly(symbol) {
159654
159682
  var _a;
159655
- return !(symbol.flags & 111551 /* Value */) && (!isInJSFile((_a = symbol.declarations) == null ? void 0 : _a[0]) || !!(symbol.flags & 788968 /* Type */));
159683
+ const flags = getCombinedLocalAndExportSymbolFlags(skipAlias(symbol, typeChecker));
159684
+ return !(flags & 111551 /* Value */) && (!isInJSFile((_a = symbol.declarations) == null ? void 0 : _a[0]) || !!(flags & 788968 /* Type */));
159656
159685
  }
159657
159686
  }
159658
159687
  function getLabelCompletionAtPosition(node) {
@@ -159948,10 +159977,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
159948
159977
  return isJsxExpression(parent2) && !isJsxElement(parent2.parent) && !isJsxFragment(parent2.parent) ? checker.getContextualTypeForJsxAttribute(parent2.parent) : void 0;
159949
159978
  default:
159950
159979
  const argInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(previousToken, position, sourceFile, checker);
159951
- return argInfo ? (
159952
- // At `,`, treat this as the next argument after the comma.
159953
- checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 28 /* CommaToken */ ? 1 : 0))
159954
- ) : isEqualityOperatorKind(previousToken.kind) && isBinaryExpression(parent2) && isEqualityOperatorKind(parent2.operatorToken.kind) ? (
159980
+ return argInfo ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex) : isEqualityOperatorKind(previousToken.kind) && isBinaryExpression(parent2) && isEqualityOperatorKind(parent2.operatorToken.kind) ? (
159955
159981
  // completion at `x ===/**/` should be for the right side
159956
159982
  checker.getTypeAtLocation(parent2.left)
159957
159983
  ) : checker.getContextualType(previousToken, 4 /* Completions */) || checker.getContextualType(previousToken);
@@ -168515,12 +168541,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
168515
168541
  if (!info)
168516
168542
  return void 0;
168517
168543
  const { list, argumentIndex } = info;
168518
- const argumentCount = getArgumentCount(
168519
- list,
168520
- /*ignoreTrailingComma*/
168521
- isInString(sourceFile, position, node),
168522
- checker
168523
- );
168544
+ const argumentCount = getArgumentCount(checker, list);
168524
168545
  if (argumentIndex !== 0) {
168525
168546
  Debug.assertLessThan(argumentIndex, argumentCount);
168526
168547
  }
@@ -168532,7 +168553,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
168532
168553
  return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 };
168533
168554
  } else {
168534
168555
  const list = findContainingList(node);
168535
- return list && { list, argumentIndex: getArgumentIndex(list, node, checker) };
168556
+ return list && { list, argumentIndex: getArgumentIndex(checker, list, node) };
168536
168557
  }
168537
168558
  }
168538
168559
  function getImmediatelyContainingArgumentInfo(node, position, sourceFile, checker) {
@@ -168662,24 +168683,6 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
168662
168683
  return isFunctionTypeNode(d) ? (_a = tryCast(d.parent, canHaveSymbol)) == null ? void 0 : _a.symbol : void 0;
168663
168684
  }) || s : s;
168664
168685
  }
168665
- function getArgumentIndex(argumentsList, node, checker) {
168666
- const args = argumentsList.getChildren();
168667
- let argumentIndex = 0;
168668
- for (let pos = 0; pos < length(args); pos++) {
168669
- const child = args[pos];
168670
- if (child === node) {
168671
- break;
168672
- }
168673
- if (isSpreadElement(child)) {
168674
- argumentIndex = argumentIndex + getSpreadElementCount(child, checker) + (pos > 0 ? pos : 0);
168675
- } else {
168676
- if (child.kind !== 28 /* CommaToken */) {
168677
- argumentIndex++;
168678
- }
168679
- }
168680
- }
168681
- return argumentIndex;
168682
- }
168683
168686
  function getSpreadElementCount(node, checker) {
168684
168687
  const spreadType = checker.getTypeAtLocation(node.expression);
168685
168688
  if (checker.isTupleType(spreadType)) {
@@ -168692,19 +168695,48 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
168692
168695
  }
168693
168696
  return 0;
168694
168697
  }
168695
- function getArgumentCount(argumentsList, ignoreTrailingComma, checker) {
168696
- const listChildren = argumentsList.getChildren();
168697
- let argumentCount = 0;
168698
- for (const child of listChildren) {
168698
+ function getArgumentIndex(checker, argumentsList, node) {
168699
+ return getArgumentIndexOrCount(checker, argumentsList, node);
168700
+ }
168701
+ function getArgumentCount(checker, argumentsList) {
168702
+ return getArgumentIndexOrCount(
168703
+ checker,
168704
+ argumentsList,
168705
+ /*node*/
168706
+ void 0
168707
+ );
168708
+ }
168709
+ function getArgumentIndexOrCount(checker, argumentsList, node) {
168710
+ const args = argumentsList.getChildren();
168711
+ let argumentIndex = 0;
168712
+ let skipComma = false;
168713
+ for (const child of args) {
168714
+ if (node && child === node) {
168715
+ if (!skipComma && child.kind === 28 /* CommaToken */) {
168716
+ argumentIndex++;
168717
+ }
168718
+ return argumentIndex;
168719
+ }
168699
168720
  if (isSpreadElement(child)) {
168700
- argumentCount = argumentCount + getSpreadElementCount(child, checker);
168721
+ argumentIndex += getSpreadElementCount(child, checker);
168722
+ skipComma = true;
168723
+ continue;
168724
+ }
168725
+ if (child.kind !== 28 /* CommaToken */) {
168726
+ argumentIndex++;
168727
+ skipComma = true;
168728
+ continue;
168701
168729
  }
168730
+ if (skipComma) {
168731
+ skipComma = false;
168732
+ continue;
168733
+ }
168734
+ argumentIndex++;
168702
168735
  }
168703
- argumentCount = argumentCount + countWhere(listChildren, (arg) => arg.kind !== 28 /* CommaToken */);
168704
- if (!ignoreTrailingComma && listChildren.length > 0 && last(listChildren).kind === 28 /* CommaToken */) {
168705
- argumentCount++;
168736
+ if (node) {
168737
+ return argumentIndex;
168706
168738
  }
168707
- return argumentCount;
168739
+ return args.length && last(args).kind === 28 /* CommaToken */ ? argumentIndex + 1 : argumentIndex;
168708
168740
  }
168709
168741
  function getArgumentIndexForTemplatePiece(spanIndex, node, position, sourceFile) {
168710
168742
  Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node.");
@@ -178292,7 +178324,16 @@ ${options.prefix}` : "\n" : options.prefix
178292
178324
  recursive ? watchedDirectoriesRecursive : watchedDirectories,
178293
178325
  path,
178294
178326
  callback,
178295
- (id) => ({ eventName: CreateDirectoryWatcherEvent, data: { id, path, recursive: !!recursive } })
178327
+ (id) => ({
178328
+ eventName: CreateDirectoryWatcherEvent,
178329
+ data: {
178330
+ id,
178331
+ path,
178332
+ recursive: !!recursive,
178333
+ // Special case node_modules as we watch it for changes to closed script infos as well
178334
+ ignoreUpdate: !path.endsWith("/node_modules") ? true : void 0
178335
+ }
178336
+ })
178296
178337
  );
178297
178338
  }
178298
178339
  function getOrCreateFileWatcher({ pathToId, idToCallbacks }, path, callback, event) {
@@ -178319,24 +178360,28 @@ ${options.prefix}` : "\n" : options.prefix
178319
178360
  }
178320
178361
  };
178321
178362
  }
178322
- function onWatchChange({ id, path, eventType }) {
178323
- onFileWatcherCallback(id, path, eventType);
178324
- onDirectoryWatcherCallback(watchedDirectories, id, path, eventType);
178325
- onDirectoryWatcherCallback(watchedDirectoriesRecursive, id, path, eventType);
178363
+ function onWatchChange(args) {
178364
+ if (isArray(args))
178365
+ args.forEach(onWatchChangeRequestArgs);
178366
+ else
178367
+ onWatchChangeRequestArgs(args);
178326
178368
  }
178327
- function onFileWatcherCallback(id, eventPath, eventType) {
178328
- var _a;
178329
- (_a = watchedFiles.idToCallbacks.get(id)) == null ? void 0 : _a.forEach((callback) => {
178330
- const eventKind = eventType === "create" ? 0 /* Created */ : eventType === "delete" ? 2 /* Deleted */ : 1 /* Changed */;
178331
- callback(eventPath, eventKind);
178332
- });
178369
+ function onWatchChangeRequestArgs({ id, created, deleted, updated }) {
178370
+ onWatchEventType(id, created, 0 /* Created */);
178371
+ onWatchEventType(id, deleted, 2 /* Deleted */);
178372
+ onWatchEventType(id, updated, 1 /* Changed */);
178333
178373
  }
178334
- function onDirectoryWatcherCallback({ idToCallbacks }, id, eventPath, eventType) {
178335
- var _a;
178336
- if (eventType === "update")
178374
+ function onWatchEventType(id, paths, eventKind) {
178375
+ if (!(paths == null ? void 0 : paths.length))
178337
178376
  return;
178338
- (_a = idToCallbacks.get(id)) == null ? void 0 : _a.forEach((callback) => {
178339
- callback(eventPath);
178377
+ forEachCallback(watchedFiles, id, paths, (callback, eventPath) => callback(eventPath, eventKind));
178378
+ forEachCallback(watchedDirectories, id, paths, (callback, eventPath) => callback(eventPath));
178379
+ forEachCallback(watchedDirectoriesRecursive, id, paths, (callback, eventPath) => callback(eventPath));
178380
+ }
178381
+ function forEachCallback(hostWatcherMap, id, eventPaths, cb) {
178382
+ var _a;
178383
+ (_a = hostWatcherMap.idToCallbacks.get(id)) == null ? void 0 : _a.forEach((callback) => {
178384
+ eventPaths.forEach((eventPath) => cb(callback, normalizeSlashes(eventPath)));
178340
178385
  });
178341
178386
  }
178342
178387
  }