typescript 5.4.2 → 5.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/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.4";
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)) {
@@ -57820,13 +57846,16 @@ ${lanes.join("\n")}
57820
57846
  const constraint = getConstraintTypeFromMappedType(type);
57821
57847
  if (constraint.flags & 4194304 /* Index */) {
57822
57848
  const baseConstraint = getBaseConstraintOfType(constraint.type);
57823
- if (baseConstraint && everyType(baseConstraint, isArrayOrTupleType)) {
57849
+ if (baseConstraint && everyType(baseConstraint, (t) => isArrayOrTupleType(t) || isArrayOrTupleOrIntersection(t))) {
57824
57850
  return instantiateType(target, prependTypeMapping(typeVariable, baseConstraint, type.mapper));
57825
57851
  }
57826
57852
  }
57827
57853
  }
57828
57854
  return type;
57829
57855
  }
57856
+ function isArrayOrTupleOrIntersection(type) {
57857
+ return !!(type.flags & 2097152 /* Intersection */) && every(type.types, isArrayOrTupleType);
57858
+ }
57830
57859
  function isMappedTypeGenericIndexedAccess(type) {
57831
57860
  let objectType;
57832
57861
  return !!(type.flags & 8388608 /* IndexedAccess */ && getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType);
@@ -60465,7 +60494,7 @@ ${lanes.join("\n")}
60465
60494
  const typeVarIndex = typeSet[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
60466
60495
  const typeVariable = typeSet[typeVarIndex];
60467
60496
  const primitiveType = typeSet[1 - typeVarIndex];
60468
- if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) || includes & 16777216 /* IncludesEmptyObject */)) {
60497
+ if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) && !isGenericStringLikeType(primitiveType) || includes & 16777216 /* IncludesEmptyObject */)) {
60469
60498
  const constraint = getBaseConstraintOfType(typeVariable);
60470
60499
  if (constraint && everyType(constraint, (t) => !!(t.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */)) || isEmptyAnonymousObjectType(t))) {
60471
60500
  if (isTypeStrictSubtypeOf(constraint, primitiveType)) {
@@ -60493,6 +60522,9 @@ ${lanes.join("\n")}
60493
60522
  } else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
60494
60523
  removeFromEach(typeSet, 65536 /* Null */);
60495
60524
  result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
60525
+ } else if (typeSet.length >= 4) {
60526
+ const middle = Math.floor(typeSet.length / 2);
60527
+ result = getIntersectionType([getIntersectionType(typeSet.slice(0, middle)), getIntersectionType(typeSet.slice(middle))], aliasSymbol, aliasTypeArguments);
60496
60528
  } else {
60497
60529
  if (!checkCrossProductUnion(typeSet)) {
60498
60530
  return errorType;
@@ -61073,6 +61105,9 @@ ${lanes.join("\n")}
61073
61105
  function isPatternLiteralType(type) {
61074
61106
  return !!(type.flags & 134217728 /* TemplateLiteral */) && every(type.types, isPatternLiteralPlaceholderType) || !!(type.flags & 268435456 /* StringMapping */) && isPatternLiteralPlaceholderType(type.type);
61075
61107
  }
61108
+ function isGenericStringLikeType(type) {
61109
+ return !!(type.flags & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) && !isPatternLiteralType(type);
61110
+ }
61076
61111
  function isGenericType(type) {
61077
61112
  return !!getGenericObjectFlags(type);
61078
61113
  }
@@ -61095,7 +61130,7 @@ ${lanes.join("\n")}
61095
61130
  }
61096
61131
  return type.objectFlags & 12582912 /* IsGenericType */;
61097
61132
  }
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);
61133
+ return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */) || isGenericStringLikeType(type) ? 8388608 /* IsGenericIndexType */ : 0);
61099
61134
  }
61100
61135
  function getSimplifiedType(type, writing) {
61101
61136
  return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : type;
@@ -62194,29 +62229,28 @@ ${lanes.join("\n")}
62194
62229
  if (typeVariable) {
62195
62230
  const mappedTypeVariable = instantiateType(typeVariable, mapper);
62196
62231
  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
- );
62232
+ return mapTypeWithAlias(getReducedType(mappedTypeVariable), instantiateConstituent, aliasSymbol, aliasTypeArguments);
62217
62233
  }
62218
62234
  }
62219
62235
  return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments);
62236
+ function instantiateConstituent(t) {
62237
+ if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
62238
+ if (!type.declaration.nameType) {
62239
+ let constraint;
62240
+ if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
62241
+ return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
62242
+ }
62243
+ if (isTupleType(t)) {
62244
+ return instantiateMappedTupleType(t, type, typeVariable, mapper);
62245
+ }
62246
+ if (isArrayOrTupleOrIntersection(t)) {
62247
+ return getIntersectionType(map(t.types, instantiateConstituent));
62248
+ }
62249
+ }
62250
+ return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
62251
+ }
62252
+ return t;
62253
+ }
62220
62254
  }
62221
62255
  function getModifiedReadonlyState(state, modifiers) {
62222
62256
  return modifiers & 1 /* IncludeReadonly */ ? true : modifiers & 2 /* ExcludeReadonly */ ? false : state;
@@ -68143,7 +68177,7 @@ ${lanes.join("\n")}
68143
68177
  function hasMatchingArgument(expression, reference) {
68144
68178
  if (expression.arguments) {
68145
68179
  for (const argument of expression.arguments) {
68146
- if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference) || getCandidateDiscriminantPropertyAccess(argument, reference)) {
68180
+ if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference)) {
68147
68181
  return true;
68148
68182
  }
68149
68183
  }
@@ -68153,36 +68187,6 @@ ${lanes.join("\n")}
68153
68187
  }
68154
68188
  return false;
68155
68189
  }
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
68190
  function getFlowNodeId(flow) {
68187
68191
  if (!flow.id || flow.id < 0) {
68188
68192
  flow.id = nextFlowId;
@@ -69282,9 +69286,39 @@ ${lanes.join("\n")}
69282
69286
  }
69283
69287
  return result;
69284
69288
  }
69289
+ function getCandidateDiscriminantPropertyAccess(expr) {
69290
+ if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) {
69291
+ if (isIdentifier(expr)) {
69292
+ const symbol = getResolvedSymbol(expr);
69293
+ const declaration = symbol.valueDeclaration;
69294
+ if (declaration && (isBindingElement(declaration) || isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
69295
+ return declaration;
69296
+ }
69297
+ }
69298
+ } else if (isAccessExpression(expr)) {
69299
+ if (isMatchingReference(reference, expr.expression)) {
69300
+ return expr;
69301
+ }
69302
+ } else if (isIdentifier(expr)) {
69303
+ const symbol = getResolvedSymbol(expr);
69304
+ if (isConstantVariable(symbol)) {
69305
+ const declaration = symbol.valueDeclaration;
69306
+ if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && isMatchingReference(reference, declaration.initializer.expression)) {
69307
+ return declaration.initializer;
69308
+ }
69309
+ if (isBindingElement(declaration) && !declaration.initializer) {
69310
+ const parent2 = declaration.parent.parent;
69311
+ if (isVariableDeclaration(parent2) && !parent2.type && parent2.initializer && (isIdentifier(parent2.initializer) || isAccessExpression(parent2.initializer)) && isMatchingReference(reference, parent2.initializer)) {
69312
+ return declaration;
69313
+ }
69314
+ }
69315
+ }
69316
+ }
69317
+ return void 0;
69318
+ }
69285
69319
  function getDiscriminantPropertyAccess(expr, computedType) {
69286
69320
  if (declaredType.flags & 1048576 /* Union */ || computedType.flags & 1048576 /* Union */) {
69287
- const access = getCandidateDiscriminantPropertyAccess(expr, reference);
69321
+ const access = getCandidateDiscriminantPropertyAccess(expr);
69288
69322
  if (access) {
69289
69323
  const name = getAccessedPropertyName(access);
69290
69324
  if (name) {
@@ -75005,7 +75039,7 @@ ${lanes.join("\n")}
75005
75039
  }
75006
75040
  return resolveErrorCall(node);
75007
75041
  }
75008
- if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunctionOrConstructor)) {
75042
+ if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
75009
75043
  skippedGenericFunction(node, checkMode);
75010
75044
  return resolvingSignature;
75011
75045
  }
@@ -75015,12 +75049,8 @@ ${lanes.join("\n")}
75015
75049
  }
75016
75050
  return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
75017
75051
  }
75018
- function isGenericFunctionReturningFunctionOrConstructor(signature) {
75019
- if (!signature.typeParameters) {
75020
- return false;
75021
- }
75022
- const returnType = getReturnTypeOfSignature(signature);
75023
- return isFunctionType(returnType) || isConstructorType(returnType);
75052
+ function isGenericFunctionReturningFunction(signature) {
75053
+ return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
75024
75054
  }
75025
75055
  function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
75026
75056
  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 +83207,7 @@ ${lanes.join("\n")}
83177
83207
  error2(member.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums);
83178
83208
  } else {
83179
83209
  const text = getTextOfPropertyName(member.name);
83180
- if (isNumericLiteralName(text)) {
83210
+ if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) {
83181
83211
  error2(member.name, Diagnostics.An_enum_member_cannot_have_a_numeric_name);
83182
83212
  }
83183
83213
  }
@@ -159948,10 +159978,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
159948
159978
  return isJsxExpression(parent2) && !isJsxElement(parent2.parent) && !isJsxFragment(parent2.parent) ? checker.getContextualTypeForJsxAttribute(parent2.parent) : void 0;
159949
159979
  default:
159950
159980
  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) ? (
159981
+ return argInfo ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex) : isEqualityOperatorKind(previousToken.kind) && isBinaryExpression(parent2) && isEqualityOperatorKind(parent2.operatorToken.kind) ? (
159955
159982
  // completion at `x ===/**/` should be for the right side
159956
159983
  checker.getTypeAtLocation(parent2.left)
159957
159984
  ) : checker.getContextualType(previousToken, 4 /* Completions */) || checker.getContextualType(previousToken);
@@ -168515,12 +168542,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
168515
168542
  if (!info)
168516
168543
  return void 0;
168517
168544
  const { list, argumentIndex } = info;
168518
- const argumentCount = getArgumentCount(
168519
- list,
168520
- /*ignoreTrailingComma*/
168521
- isInString(sourceFile, position, node),
168522
- checker
168523
- );
168545
+ const argumentCount = getArgumentCount(checker, list);
168524
168546
  if (argumentIndex !== 0) {
168525
168547
  Debug.assertLessThan(argumentIndex, argumentCount);
168526
168548
  }
@@ -168532,7 +168554,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
168532
168554
  return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 };
168533
168555
  } else {
168534
168556
  const list = findContainingList(node);
168535
- return list && { list, argumentIndex: getArgumentIndex(list, node, checker) };
168557
+ return list && { list, argumentIndex: getArgumentIndex(checker, list, node) };
168536
168558
  }
168537
168559
  }
168538
168560
  function getImmediatelyContainingArgumentInfo(node, position, sourceFile, checker) {
@@ -168662,24 +168684,6 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
168662
168684
  return isFunctionTypeNode(d) ? (_a = tryCast(d.parent, canHaveSymbol)) == null ? void 0 : _a.symbol : void 0;
168663
168685
  }) || s : s;
168664
168686
  }
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
168687
  function getSpreadElementCount(node, checker) {
168684
168688
  const spreadType = checker.getTypeAtLocation(node.expression);
168685
168689
  if (checker.isTupleType(spreadType)) {
@@ -168692,19 +168696,48 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
168692
168696
  }
168693
168697
  return 0;
168694
168698
  }
168695
- function getArgumentCount(argumentsList, ignoreTrailingComma, checker) {
168696
- const listChildren = argumentsList.getChildren();
168697
- let argumentCount = 0;
168698
- for (const child of listChildren) {
168699
+ function getArgumentIndex(checker, argumentsList, node) {
168700
+ return getArgumentIndexOrCount(checker, argumentsList, node);
168701
+ }
168702
+ function getArgumentCount(checker, argumentsList) {
168703
+ return getArgumentIndexOrCount(
168704
+ checker,
168705
+ argumentsList,
168706
+ /*node*/
168707
+ void 0
168708
+ );
168709
+ }
168710
+ function getArgumentIndexOrCount(checker, argumentsList, node) {
168711
+ const args = argumentsList.getChildren();
168712
+ let argumentIndex = 0;
168713
+ let skipComma = false;
168714
+ for (const child of args) {
168715
+ if (node && child === node) {
168716
+ if (!skipComma && child.kind === 28 /* CommaToken */) {
168717
+ argumentIndex++;
168718
+ }
168719
+ return argumentIndex;
168720
+ }
168699
168721
  if (isSpreadElement(child)) {
168700
- argumentCount = argumentCount + getSpreadElementCount(child, checker);
168722
+ argumentIndex += getSpreadElementCount(child, checker);
168723
+ skipComma = true;
168724
+ continue;
168725
+ }
168726
+ if (child.kind !== 28 /* CommaToken */) {
168727
+ argumentIndex++;
168728
+ skipComma = true;
168729
+ continue;
168701
168730
  }
168731
+ if (skipComma) {
168732
+ skipComma = false;
168733
+ continue;
168734
+ }
168735
+ argumentIndex++;
168702
168736
  }
168703
- argumentCount = argumentCount + countWhere(listChildren, (arg) => arg.kind !== 28 /* CommaToken */);
168704
- if (!ignoreTrailingComma && listChildren.length > 0 && last(listChildren).kind === 28 /* CommaToken */) {
168705
- argumentCount++;
168737
+ if (node) {
168738
+ return argumentIndex;
168706
168739
  }
168707
- return argumentCount;
168740
+ return args.length && last(args).kind === 28 /* CommaToken */ ? argumentIndex + 1 : argumentIndex;
168708
168741
  }
168709
168742
  function getArgumentIndexForTemplatePiece(spanIndex, node, position, sourceFile) {
168710
168743
  Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node.");
@@ -178292,7 +178325,16 @@ ${options.prefix}` : "\n" : options.prefix
178292
178325
  recursive ? watchedDirectoriesRecursive : watchedDirectories,
178293
178326
  path,
178294
178327
  callback,
178295
- (id) => ({ eventName: CreateDirectoryWatcherEvent, data: { id, path, recursive: !!recursive } })
178328
+ (id) => ({
178329
+ eventName: CreateDirectoryWatcherEvent,
178330
+ data: {
178331
+ id,
178332
+ path,
178333
+ recursive: !!recursive,
178334
+ // Special case node_modules as we watch it for changes to closed script infos as well
178335
+ ignoreUpdate: !path.endsWith("/node_modules") ? true : void 0
178336
+ }
178337
+ })
178296
178338
  );
178297
178339
  }
178298
178340
  function getOrCreateFileWatcher({ pathToId, idToCallbacks }, path, callback, event) {
@@ -178319,24 +178361,28 @@ ${options.prefix}` : "\n" : options.prefix
178319
178361
  }
178320
178362
  };
178321
178363
  }
178322
- function onWatchChange({ id, path, eventType }) {
178323
- onFileWatcherCallback(id, path, eventType);
178324
- onDirectoryWatcherCallback(watchedDirectories, id, path, eventType);
178325
- onDirectoryWatcherCallback(watchedDirectoriesRecursive, id, path, eventType);
178364
+ function onWatchChange(args) {
178365
+ if (isArray(args))
178366
+ args.forEach(onWatchChangeRequestArgs);
178367
+ else
178368
+ onWatchChangeRequestArgs(args);
178326
178369
  }
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
- });
178370
+ function onWatchChangeRequestArgs({ id, created, deleted, updated }) {
178371
+ onWatchEventType(id, created, 0 /* Created */);
178372
+ onWatchEventType(id, deleted, 2 /* Deleted */);
178373
+ onWatchEventType(id, updated, 1 /* Changed */);
178333
178374
  }
178334
- function onDirectoryWatcherCallback({ idToCallbacks }, id, eventPath, eventType) {
178335
- var _a;
178336
- if (eventType === "update")
178375
+ function onWatchEventType(id, paths, eventKind) {
178376
+ if (!(paths == null ? void 0 : paths.length))
178337
178377
  return;
178338
- (_a = idToCallbacks.get(id)) == null ? void 0 : _a.forEach((callback) => {
178339
- callback(eventPath);
178378
+ forEachCallback(watchedFiles, id, paths, (callback, eventPath) => callback(eventPath, eventKind));
178379
+ forEachCallback(watchedDirectories, id, paths, (callback, eventPath) => callback(eventPath));
178380
+ forEachCallback(watchedDirectoriesRecursive, id, paths, (callback, eventPath) => callback(eventPath));
178381
+ }
178382
+ function forEachCallback(hostWatcherMap, id, eventPaths, cb) {
178383
+ var _a;
178384
+ (_a = hostWatcherMap.idToCallbacks.get(id)) == null ? void 0 : _a.forEach((callback) => {
178385
+ eventPaths.forEach((eventPath) => cb(callback, normalizeSlashes(eventPath)));
178340
178386
  });
178341
178387
  }
178342
178388
  }
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.4";
57
- var version = "5.4.2";
57
+ var version = "5.4.4";
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
@@ -3560,14 +3560,17 @@ function createDynamicPriorityPollingWatchFile(host) {
3560
3560
  pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === 250 /* Low */ ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingInterval === 250 /* Low */ ? "pollLowPollingIntervalQueue" : "pollPollingIntervalQueue", pollingIntervalQueue(pollingInterval));
3561
3561
  }
3562
3562
  }
3563
- function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames2) {
3563
+ function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames2, getModifiedTime2, fsWatchWithTimestamp) {
3564
3564
  const fileWatcherCallbacks = createMultiMap();
3565
+ const fileTimestamps = fsWatchWithTimestamp ? /* @__PURE__ */ new Map() : void 0;
3565
3566
  const dirWatchers = /* @__PURE__ */ new Map();
3566
3567
  const toCanonicalName = createGetCanonicalFileName(useCaseSensitiveFileNames2);
3567
3568
  return nonPollingWatchFile;
3568
3569
  function nonPollingWatchFile(fileName, callback, _pollingInterval, fallbackOptions) {
3569
3570
  const filePath = toCanonicalName(fileName);
3570
- fileWatcherCallbacks.add(filePath, callback);
3571
+ if (fileWatcherCallbacks.add(filePath, callback).length === 1 && fileTimestamps) {
3572
+ fileTimestamps.set(filePath, getModifiedTime2(fileName) || missingFileModifiedTime);
3573
+ }
3571
3574
  const dirPath = getDirectoryPath(filePath) || ".";
3572
3575
  const watcher = dirWatchers.get(dirPath) || createDirectoryWatcher(getDirectoryPath(fileName) || ".", dirPath, fallbackOptions);
3573
3576
  watcher.referenceCount++;
@@ -3587,14 +3590,31 @@ function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFi
3587
3590
  const watcher = fsWatch(
3588
3591
  dirName,
3589
3592
  1 /* Directory */,
3590
- (_eventName, relativeFileName, modifiedTime) => {
3593
+ (eventName, relativeFileName) => {
3591
3594
  if (!isString(relativeFileName))
3592
3595
  return;
3593
3596
  const fileName = getNormalizedAbsolutePath(relativeFileName, dirName);
3594
- const callbacks = fileName && fileWatcherCallbacks.get(toCanonicalName(fileName));
3597
+ const filePath = toCanonicalName(fileName);
3598
+ const callbacks = fileName && fileWatcherCallbacks.get(filePath);
3595
3599
  if (callbacks) {
3600
+ let currentModifiedTime;
3601
+ let eventKind = 1 /* Changed */;
3602
+ if (fileTimestamps) {
3603
+ const existingTime = fileTimestamps.get(filePath);
3604
+ if (eventName === "change") {
3605
+ currentModifiedTime = getModifiedTime2(fileName) || missingFileModifiedTime;
3606
+ if (currentModifiedTime.getTime() === existingTime.getTime())
3607
+ return;
3608
+ }
3609
+ currentModifiedTime || (currentModifiedTime = getModifiedTime2(fileName) || missingFileModifiedTime);
3610
+ fileTimestamps.set(filePath, currentModifiedTime);
3611
+ if (existingTime === missingFileModifiedTime)
3612
+ eventKind = 0 /* Created */;
3613
+ else if (currentModifiedTime === missingFileModifiedTime)
3614
+ eventKind = 2 /* Deleted */;
3615
+ }
3596
3616
  for (const fileCallback of callbacks) {
3597
- fileCallback(fileName, 1 /* Changed */, modifiedTime);
3617
+ fileCallback(fileName, eventKind, currentModifiedTime);
3598
3618
  }
3599
3619
  }
3600
3620
  },
@@ -3985,7 +4005,7 @@ function createSystemWatchFunctions({
3985
4005
  );
3986
4006
  case 5 /* UseFsEventsOnParentDirectory */:
3987
4007
  if (!nonPollingWatchFile) {
3988
- nonPollingWatchFile = createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames2);
4008
+ nonPollingWatchFile = createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames2, getModifiedTime2, fsWatchWithTimestamp);
3989
4009
  }
3990
4010
  return nonPollingWatchFile(fileName, callback, pollingInterval, getFallbackOptions(options));
3991
4011
  default:
@@ -4160,7 +4180,7 @@ function createSystemWatchFunctions({
4160
4180
  return watchPresentFileSystemEntryWithFsWatchFile();
4161
4181
  }
4162
4182
  try {
4163
- const presentWatcher = (!fsWatchWithTimestamp ? fsWatchWorker : fsWatchWorkerHandlingTimestamp)(
4183
+ const presentWatcher = (entryKind === 1 /* Directory */ || !fsWatchWithTimestamp ? fsWatchWorker : fsWatchWorkerHandlingTimestamp)(
4164
4184
  fileOrDirectory,
4165
4185
  recursive,
4166
4186
  inodeWatching ? callbackChangingToMissingFileSystemEntry : callback
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.4.2",
5
+ "version": "5.4.4",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [