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/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.4";
21
- var version = "5.4.2";
21
+ var version = "5.4.4";
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -4145,14 +4145,17 @@ function createDynamicPriorityPollingWatchFile(host) {
4145
4145
  pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === 250 /* Low */ ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingInterval === 250 /* Low */ ? "pollLowPollingIntervalQueue" : "pollPollingIntervalQueue", pollingIntervalQueue(pollingInterval));
4146
4146
  }
4147
4147
  }
4148
- function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames2) {
4148
+ function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames2, getModifiedTime3, fsWatchWithTimestamp) {
4149
4149
  const fileWatcherCallbacks = createMultiMap();
4150
+ const fileTimestamps = fsWatchWithTimestamp ? /* @__PURE__ */ new Map() : void 0;
4150
4151
  const dirWatchers = /* @__PURE__ */ new Map();
4151
4152
  const toCanonicalName = createGetCanonicalFileName(useCaseSensitiveFileNames2);
4152
4153
  return nonPollingWatchFile;
4153
4154
  function nonPollingWatchFile(fileName, callback, _pollingInterval, fallbackOptions) {
4154
4155
  const filePath = toCanonicalName(fileName);
4155
- fileWatcherCallbacks.add(filePath, callback);
4156
+ if (fileWatcherCallbacks.add(filePath, callback).length === 1 && fileTimestamps) {
4157
+ fileTimestamps.set(filePath, getModifiedTime3(fileName) || missingFileModifiedTime);
4158
+ }
4156
4159
  const dirPath = getDirectoryPath(filePath) || ".";
4157
4160
  const watcher = dirWatchers.get(dirPath) || createDirectoryWatcher(getDirectoryPath(fileName) || ".", dirPath, fallbackOptions);
4158
4161
  watcher.referenceCount++;
@@ -4172,14 +4175,31 @@ function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFi
4172
4175
  const watcher = fsWatch(
4173
4176
  dirName,
4174
4177
  1 /* Directory */,
4175
- (_eventName, relativeFileName, modifiedTime) => {
4178
+ (eventName, relativeFileName) => {
4176
4179
  if (!isString(relativeFileName))
4177
4180
  return;
4178
4181
  const fileName = getNormalizedAbsolutePath(relativeFileName, dirName);
4179
- const callbacks = fileName && fileWatcherCallbacks.get(toCanonicalName(fileName));
4182
+ const filePath = toCanonicalName(fileName);
4183
+ const callbacks = fileName && fileWatcherCallbacks.get(filePath);
4180
4184
  if (callbacks) {
4185
+ let currentModifiedTime;
4186
+ let eventKind = 1 /* Changed */;
4187
+ if (fileTimestamps) {
4188
+ const existingTime = fileTimestamps.get(filePath);
4189
+ if (eventName === "change") {
4190
+ currentModifiedTime = getModifiedTime3(fileName) || missingFileModifiedTime;
4191
+ if (currentModifiedTime.getTime() === existingTime.getTime())
4192
+ return;
4193
+ }
4194
+ currentModifiedTime || (currentModifiedTime = getModifiedTime3(fileName) || missingFileModifiedTime);
4195
+ fileTimestamps.set(filePath, currentModifiedTime);
4196
+ if (existingTime === missingFileModifiedTime)
4197
+ eventKind = 0 /* Created */;
4198
+ else if (currentModifiedTime === missingFileModifiedTime)
4199
+ eventKind = 2 /* Deleted */;
4200
+ }
4181
4201
  for (const fileCallback of callbacks) {
4182
- fileCallback(fileName, 1 /* Changed */, modifiedTime);
4202
+ fileCallback(fileName, eventKind, currentModifiedTime);
4183
4203
  }
4184
4204
  }
4185
4205
  },
@@ -4573,7 +4593,7 @@ function createSystemWatchFunctions({
4573
4593
  );
4574
4594
  case 5 /* UseFsEventsOnParentDirectory */:
4575
4595
  if (!nonPollingWatchFile) {
4576
- nonPollingWatchFile = createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames2);
4596
+ nonPollingWatchFile = createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames2, getModifiedTime3, fsWatchWithTimestamp);
4577
4597
  }
4578
4598
  return nonPollingWatchFile(fileName, callback, pollingInterval, getFallbackOptions(options));
4579
4599
  default:
@@ -4748,7 +4768,7 @@ function createSystemWatchFunctions({
4748
4768
  return watchPresentFileSystemEntryWithFsWatchFile();
4749
4769
  }
4750
4770
  try {
4751
- const presentWatcher = (!fsWatchWithTimestamp ? fsWatchWorker : fsWatchWorkerHandlingTimestamp)(
4771
+ const presentWatcher = (entryKind === 1 /* Directory */ || !fsWatchWithTimestamp ? fsWatchWorker : fsWatchWorkerHandlingTimestamp)(
4752
4772
  fileOrDirectory,
4753
4773
  recursive,
4754
4774
  inodeWatching ? callbackChangingToMissingFileSystemEntry : callback
@@ -42862,13 +42882,21 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
42862
42882
  }
42863
42883
  const nearestTargetPackageJson = getNearestAncestorDirectoryWithPackageJson(host, getDirectoryPath(modulePath));
42864
42884
  const nearestSourcePackageJson = getNearestAncestorDirectoryWithPackageJson(host, sourceDirectory);
42865
- if (nearestSourcePackageJson !== nearestTargetPackageJson) {
42885
+ const ignoreCase = !hostUsesCaseSensitiveFileNames(host);
42886
+ if (!packageJsonPathsAreEqual(nearestTargetPackageJson, nearestSourcePackageJson, ignoreCase)) {
42866
42887
  return maybeNonRelative;
42867
42888
  }
42868
42889
  return relativePath;
42869
42890
  }
42870
42891
  return isPathRelativeToParent(maybeNonRelative) || countPathComponents(relativePath) < countPathComponents(maybeNonRelative) ? relativePath : maybeNonRelative;
42871
42892
  }
42893
+ function packageJsonPathsAreEqual(a, b, ignoreCase) {
42894
+ if (a === b)
42895
+ return true;
42896
+ if (a === void 0 || b === void 0)
42897
+ return false;
42898
+ return comparePaths(a, b, ignoreCase) === 0 /* EqualTo */;
42899
+ }
42872
42900
  function countPathComponents(path) {
42873
42901
  let count = 0;
42874
42902
  for (let i = startsWith(path, "./") ? 2 : 0; i < path.length; i++) {
@@ -47517,13 +47545,6 @@ function createTypeChecker(host) {
47517
47545
  });
47518
47546
  }
47519
47547
  function getSymbolIfSameReference(s1, s2) {
47520
- var _a, _b;
47521
- if (s1.flags & 524288 /* TypeAlias */ && ((_a = s2.declarations) == null ? void 0 : _a.find(isTypeAlias))) {
47522
- s2 = getDeclaredTypeOfTypeAlias(s2).aliasSymbol || s2;
47523
- }
47524
- if (s2.flags & 524288 /* TypeAlias */ && ((_b = s1.declarations) == null ? void 0 : _b.find(isTypeAlias))) {
47525
- s1 = getDeclaredTypeOfTypeAlias(s1).aliasSymbol || s1;
47526
- }
47527
47548
  if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
47528
47549
  return s1;
47529
47550
  }
@@ -48003,15 +48024,19 @@ function createTypeChecker(host) {
48003
48024
  return true;
48004
48025
  }
48005
48026
  }
48006
- function isEntityNameVisible(entityName, enclosingDeclaration) {
48027
+ function getMeaningOfEntityNameReference(entityName) {
48007
48028
  let meaning;
48008
48029
  if (entityName.parent.kind === 186 /* TypeQuery */ || entityName.parent.kind === 233 /* ExpressionWithTypeArguments */ && !isPartOfTypeNode(entityName.parent) || entityName.parent.kind === 167 /* ComputedPropertyName */) {
48009
48030
  meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
48010
- } else if (entityName.kind === 166 /* QualifiedName */ || entityName.kind === 211 /* PropertyAccessExpression */ || entityName.parent.kind === 271 /* ImportEqualsDeclaration */) {
48031
+ } 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) {
48011
48032
  meaning = 1920 /* Namespace */;
48012
48033
  } else {
48013
48034
  meaning = 788968 /* Type */;
48014
48035
  }
48036
+ return meaning;
48037
+ }
48038
+ function isEntityNameVisible(entityName, enclosingDeclaration) {
48039
+ const meaning = getMeaningOfEntityNameReference(entityName);
48015
48040
  const firstIdentifier = getFirstIdentifier(entityName);
48016
48041
  const symbol = resolveName(
48017
48042
  enclosingDeclaration,
@@ -50072,9 +50097,10 @@ function createTypeChecker(host) {
50072
50097
  introducesError = true;
50073
50098
  return { introducesError, node };
50074
50099
  }
50100
+ const meaning = getMeaningOfEntityNameReference(node);
50075
50101
  const sym = resolveEntityName(
50076
50102
  leftmost,
50077
- -1 /* All */,
50103
+ meaning,
50078
50104
  /*ignoreErrors*/
50079
50105
  true,
50080
50106
  /*dontResolveAlias*/
@@ -50084,13 +50110,13 @@ function createTypeChecker(host) {
50084
50110
  if (isSymbolAccessible(
50085
50111
  sym,
50086
50112
  context.enclosingDeclaration,
50087
- -1 /* All */,
50113
+ meaning,
50088
50114
  /*shouldComputeAliasesToMakeVisible*/
50089
50115
  false
50090
50116
  ).accessibility !== 0 /* Accessible */) {
50091
50117
  introducesError = true;
50092
50118
  } else {
50093
- context.tracker.trackSymbol(sym, context.enclosingDeclaration, -1 /* All */);
50119
+ context.tracker.trackSymbol(sym, context.enclosingDeclaration, meaning);
50094
50120
  includePrivateSymbol == null ? void 0 : includePrivateSymbol(sym);
50095
50121
  }
50096
50122
  if (isIdentifier(node)) {
@@ -55321,13 +55347,16 @@ function createTypeChecker(host) {
55321
55347
  const constraint = getConstraintTypeFromMappedType(type);
55322
55348
  if (constraint.flags & 4194304 /* Index */) {
55323
55349
  const baseConstraint = getBaseConstraintOfType(constraint.type);
55324
- if (baseConstraint && everyType(baseConstraint, isArrayOrTupleType)) {
55350
+ if (baseConstraint && everyType(baseConstraint, (t) => isArrayOrTupleType(t) || isArrayOrTupleOrIntersection(t))) {
55325
55351
  return instantiateType(target, prependTypeMapping(typeVariable, baseConstraint, type.mapper));
55326
55352
  }
55327
55353
  }
55328
55354
  }
55329
55355
  return type;
55330
55356
  }
55357
+ function isArrayOrTupleOrIntersection(type) {
55358
+ return !!(type.flags & 2097152 /* Intersection */) && every(type.types, isArrayOrTupleType);
55359
+ }
55331
55360
  function isMappedTypeGenericIndexedAccess(type) {
55332
55361
  let objectType;
55333
55362
  return !!(type.flags & 8388608 /* IndexedAccess */ && getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType);
@@ -57966,7 +57995,7 @@ function createTypeChecker(host) {
57966
57995
  const typeVarIndex = typeSet[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
57967
57996
  const typeVariable = typeSet[typeVarIndex];
57968
57997
  const primitiveType = typeSet[1 - typeVarIndex];
57969
- if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) || includes & 16777216 /* IncludesEmptyObject */)) {
57998
+ if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) && !isGenericStringLikeType(primitiveType) || includes & 16777216 /* IncludesEmptyObject */)) {
57970
57999
  const constraint = getBaseConstraintOfType(typeVariable);
57971
58000
  if (constraint && everyType(constraint, (t) => !!(t.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */)) || isEmptyAnonymousObjectType(t))) {
57972
58001
  if (isTypeStrictSubtypeOf(constraint, primitiveType)) {
@@ -57994,6 +58023,9 @@ function createTypeChecker(host) {
57994
58023
  } else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
57995
58024
  removeFromEach(typeSet, 65536 /* Null */);
57996
58025
  result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
58026
+ } else if (typeSet.length >= 4) {
58027
+ const middle = Math.floor(typeSet.length / 2);
58028
+ result = getIntersectionType([getIntersectionType(typeSet.slice(0, middle)), getIntersectionType(typeSet.slice(middle))], aliasSymbol, aliasTypeArguments);
57997
58029
  } else {
57998
58030
  if (!checkCrossProductUnion(typeSet)) {
57999
58031
  return errorType;
@@ -58574,6 +58606,9 @@ function createTypeChecker(host) {
58574
58606
  function isPatternLiteralType(type) {
58575
58607
  return !!(type.flags & 134217728 /* TemplateLiteral */) && every(type.types, isPatternLiteralPlaceholderType) || !!(type.flags & 268435456 /* StringMapping */) && isPatternLiteralPlaceholderType(type.type);
58576
58608
  }
58609
+ function isGenericStringLikeType(type) {
58610
+ return !!(type.flags & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) && !isPatternLiteralType(type);
58611
+ }
58577
58612
  function isGenericType(type) {
58578
58613
  return !!getGenericObjectFlags(type);
58579
58614
  }
@@ -58596,7 +58631,7 @@ function createTypeChecker(host) {
58596
58631
  }
58597
58632
  return type.objectFlags & 12582912 /* IsGenericType */;
58598
58633
  }
58599
- 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);
58634
+ return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */) || isGenericStringLikeType(type) ? 8388608 /* IsGenericIndexType */ : 0);
58600
58635
  }
58601
58636
  function getSimplifiedType(type, writing) {
58602
58637
  return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : type;
@@ -59695,29 +59730,28 @@ function createTypeChecker(host) {
59695
59730
  if (typeVariable) {
59696
59731
  const mappedTypeVariable = instantiateType(typeVariable, mapper);
59697
59732
  if (typeVariable !== mappedTypeVariable) {
59698
- return mapTypeWithAlias(
59699
- getReducedType(mappedTypeVariable),
59700
- (t) => {
59701
- if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
59702
- if (!type.declaration.nameType) {
59703
- let constraint;
59704
- if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
59705
- return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
59706
- }
59707
- if (isTupleType(t)) {
59708
- return instantiateMappedTupleType(t, type, typeVariable, mapper);
59709
- }
59710
- }
59711
- return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
59712
- }
59713
- return t;
59714
- },
59715
- aliasSymbol,
59716
- aliasTypeArguments
59717
- );
59733
+ return mapTypeWithAlias(getReducedType(mappedTypeVariable), instantiateConstituent, aliasSymbol, aliasTypeArguments);
59718
59734
  }
59719
59735
  }
59720
59736
  return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments);
59737
+ function instantiateConstituent(t) {
59738
+ if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
59739
+ if (!type.declaration.nameType) {
59740
+ let constraint;
59741
+ if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
59742
+ return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
59743
+ }
59744
+ if (isTupleType(t)) {
59745
+ return instantiateMappedTupleType(t, type, typeVariable, mapper);
59746
+ }
59747
+ if (isArrayOrTupleOrIntersection(t)) {
59748
+ return getIntersectionType(map(t.types, instantiateConstituent));
59749
+ }
59750
+ }
59751
+ return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
59752
+ }
59753
+ return t;
59754
+ }
59721
59755
  }
59722
59756
  function getModifiedReadonlyState(state, modifiers) {
59723
59757
  return modifiers & 1 /* IncludeReadonly */ ? true : modifiers & 2 /* ExcludeReadonly */ ? false : state;
@@ -65644,7 +65678,7 @@ function createTypeChecker(host) {
65644
65678
  function hasMatchingArgument(expression, reference) {
65645
65679
  if (expression.arguments) {
65646
65680
  for (const argument of expression.arguments) {
65647
- if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference) || getCandidateDiscriminantPropertyAccess(argument, reference)) {
65681
+ if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference)) {
65648
65682
  return true;
65649
65683
  }
65650
65684
  }
@@ -65654,36 +65688,6 @@ function createTypeChecker(host) {
65654
65688
  }
65655
65689
  return false;
65656
65690
  }
65657
- function getCandidateDiscriminantPropertyAccess(expr, reference) {
65658
- if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) {
65659
- if (isIdentifier(expr)) {
65660
- const symbol = getResolvedSymbol(expr);
65661
- const declaration = symbol.valueDeclaration;
65662
- if (declaration && (isBindingElement(declaration) || isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
65663
- return declaration;
65664
- }
65665
- }
65666
- } else if (isAccessExpression(expr)) {
65667
- if (isMatchingReference(reference, expr.expression)) {
65668
- return expr;
65669
- }
65670
- } else if (isIdentifier(expr)) {
65671
- const symbol = getResolvedSymbol(expr);
65672
- if (isConstantVariable(symbol)) {
65673
- const declaration = symbol.valueDeclaration;
65674
- if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && isMatchingReference(reference, declaration.initializer.expression)) {
65675
- return declaration.initializer;
65676
- }
65677
- if (isBindingElement(declaration) && !declaration.initializer) {
65678
- const parent = declaration.parent.parent;
65679
- if (isVariableDeclaration(parent) && !parent.type && parent.initializer && (isIdentifier(parent.initializer) || isAccessExpression(parent.initializer)) && isMatchingReference(reference, parent.initializer)) {
65680
- return declaration;
65681
- }
65682
- }
65683
- }
65684
- }
65685
- return void 0;
65686
- }
65687
65691
  function getFlowNodeId(flow) {
65688
65692
  if (!flow.id || flow.id < 0) {
65689
65693
  flow.id = nextFlowId;
@@ -66783,9 +66787,39 @@ function createTypeChecker(host) {
66783
66787
  }
66784
66788
  return result;
66785
66789
  }
66790
+ function getCandidateDiscriminantPropertyAccess(expr) {
66791
+ if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) {
66792
+ if (isIdentifier(expr)) {
66793
+ const symbol = getResolvedSymbol(expr);
66794
+ const declaration = symbol.valueDeclaration;
66795
+ if (declaration && (isBindingElement(declaration) || isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
66796
+ return declaration;
66797
+ }
66798
+ }
66799
+ } else if (isAccessExpression(expr)) {
66800
+ if (isMatchingReference(reference, expr.expression)) {
66801
+ return expr;
66802
+ }
66803
+ } else if (isIdentifier(expr)) {
66804
+ const symbol = getResolvedSymbol(expr);
66805
+ if (isConstantVariable(symbol)) {
66806
+ const declaration = symbol.valueDeclaration;
66807
+ if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && isMatchingReference(reference, declaration.initializer.expression)) {
66808
+ return declaration.initializer;
66809
+ }
66810
+ if (isBindingElement(declaration) && !declaration.initializer) {
66811
+ const parent = declaration.parent.parent;
66812
+ if (isVariableDeclaration(parent) && !parent.type && parent.initializer && (isIdentifier(parent.initializer) || isAccessExpression(parent.initializer)) && isMatchingReference(reference, parent.initializer)) {
66813
+ return declaration;
66814
+ }
66815
+ }
66816
+ }
66817
+ }
66818
+ return void 0;
66819
+ }
66786
66820
  function getDiscriminantPropertyAccess(expr, computedType) {
66787
66821
  if (declaredType.flags & 1048576 /* Union */ || computedType.flags & 1048576 /* Union */) {
66788
- const access = getCandidateDiscriminantPropertyAccess(expr, reference);
66822
+ const access = getCandidateDiscriminantPropertyAccess(expr);
66789
66823
  if (access) {
66790
66824
  const name = getAccessedPropertyName(access);
66791
66825
  if (name) {
@@ -72506,7 +72540,7 @@ function createTypeChecker(host) {
72506
72540
  }
72507
72541
  return resolveErrorCall(node);
72508
72542
  }
72509
- if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunctionOrConstructor)) {
72543
+ if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
72510
72544
  skippedGenericFunction(node, checkMode);
72511
72545
  return resolvingSignature;
72512
72546
  }
@@ -72516,12 +72550,8 @@ function createTypeChecker(host) {
72516
72550
  }
72517
72551
  return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
72518
72552
  }
72519
- function isGenericFunctionReturningFunctionOrConstructor(signature) {
72520
- if (!signature.typeParameters) {
72521
- return false;
72522
- }
72523
- const returnType = getReturnTypeOfSignature(signature);
72524
- return isFunctionType(returnType) || isConstructorType(returnType);
72553
+ function isGenericFunctionReturningFunction(signature) {
72554
+ return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
72525
72555
  }
72526
72556
  function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
72527
72557
  return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType);
@@ -80678,7 +80708,7 @@ function createTypeChecker(host) {
80678
80708
  error(member.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums);
80679
80709
  } else {
80680
80710
  const text = getTextOfPropertyName(member.name);
80681
- if (isNumericLiteralName(text)) {
80711
+ if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) {
80682
80712
  error(member.name, Diagnostics.An_enum_member_cannot_have_a_numeric_name);
80683
80713
  }
80684
80714
  }