typescript 4.8.0-dev.20220525 → 4.8.0-dev.20220528

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.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220525";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220528";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -5295,6 +5295,11 @@ var ts;
5295
5295
  // Flags that require TypeFlags.Union
5296
5296
  /* @internal */
5297
5297
  ObjectFlags[ObjectFlags["ContainsIntersections"] = 16777216] = "ContainsIntersections";
5298
+ /* @internal */
5299
+ ObjectFlags[ObjectFlags["IsUnknownLikeUnionComputed"] = 33554432] = "IsUnknownLikeUnionComputed";
5300
+ /* @internal */
5301
+ ObjectFlags[ObjectFlags["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
5302
+ /* @internal */
5298
5303
  // Flags that require TypeFlags.Intersection
5299
5304
  /* @internal */
5300
5305
  ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 16777216] = "IsNeverIntersectionComputed";
@@ -8608,6 +8613,7 @@ var ts;
8608
8613
  Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
8609
8614
  The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."),
8610
8615
  The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."),
8616
+ This_type_parameter_probably_needs_an_extends_object_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_probably_needs_an_extends_object_constraint_2208", "This type parameter probably needs an `extends object` constraint."),
8611
8617
  The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
8612
8618
  The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
8613
8619
  Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
@@ -16412,9 +16418,6 @@ var ts;
16412
16418
  }
16413
16419
  ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
16414
16420
  function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
16415
- if (node.kind === 203 /* BindingElement */) {
16416
- node = node.parent.parent;
16417
- }
16418
16421
  return ts.isVariableDeclaration(node) &&
16419
16422
  !!node.initializer &&
16420
16423
  isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
@@ -20226,8 +20229,9 @@ var ts;
20226
20229
  */
20227
20230
  function isFileForcedToBeModuleByFormat(file) {
20228
20231
  // Excludes declaration files - they still require an explicit `export {}` or the like
20229
- // for back compat purposes.
20230
- return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
20232
+ // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
20233
+ // that aren't esm-mode (meaning not in a `type: module` scope).
20234
+ return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
20231
20235
  }
20232
20236
  function getSetExternalModuleIndicator(options) {
20233
20237
  // TODO: Should this callback be cached?
@@ -20235,7 +20239,7 @@ var ts;
20235
20239
  case ts.ModuleDetectionKind.Force:
20236
20240
  // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
20237
20241
  return function (file) {
20238
- file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
20242
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
20239
20243
  };
20240
20244
  case ts.ModuleDetectionKind.Legacy:
20241
20245
  // Files are modules if they have imports, exports, or import.meta
@@ -20295,7 +20299,8 @@ var ts;
20295
20299
  }
20296
20300
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
20297
20301
  function getEmitModuleDetectionKind(options) {
20298
- return options.moduleDetection || ts.ModuleDetectionKind.Auto;
20302
+ return options.moduleDetection ||
20303
+ (getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
20299
20304
  }
20300
20305
  ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
20301
20306
  function hasJsonModuleEmitEnabled(options) {
@@ -42237,7 +42242,7 @@ var ts;
42237
42242
  }
42238
42243
  if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
42239
42244
  return {
42240
- key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
42245
+ key: ts.removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec)),
42241
42246
  flags: 1 /* Recursive */
42242
42247
  };
42243
42248
  }
@@ -43342,16 +43347,20 @@ var ts;
43342
43347
  function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
43343
43348
  return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
43344
43349
  }
43350
+ var jsOnlyExtensions = [Extensions.JavaScript];
43351
+ var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
43352
+ var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
43353
+ var tsconfigExtensions = [Extensions.TSConfig];
43345
43354
  function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
43346
43355
  var containingDirectory = ts.getDirectoryPath(containingFile);
43347
43356
  // es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features
43348
43357
  var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
43349
- return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions, redirectedReference);
43358
+ var extensions = compilerOptions.noDtsResolution ? [Extensions.TsOnly, Extensions.JavaScript] : tsExtensions;
43359
+ if (compilerOptions.resolveJsonModule) {
43360
+ extensions = __spreadArray(__spreadArray([], extensions, true), [Extensions.Json], false);
43361
+ }
43362
+ return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference);
43350
43363
  }
43351
- var jsOnlyExtensions = [Extensions.JavaScript];
43352
- var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
43353
- var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
43354
- var tsconfigExtensions = [Extensions.TSConfig];
43355
43364
  function tryResolveJSModuleWorker(moduleName, initialDir, host) {
43356
43365
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
43357
43366
  }
@@ -47136,12 +47145,14 @@ var ts;
47136
47145
  }
47137
47146
  }
47138
47147
  function setCommonJsModuleIndicator(node) {
47139
- if (file.externalModuleIndicator) {
47148
+ if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
47140
47149
  return false;
47141
47150
  }
47142
47151
  if (!file.commonJsModuleIndicator) {
47143
47152
  file.commonJsModuleIndicator = node;
47144
- bindSourceFileAsExternalModule();
47153
+ if (!file.externalModuleIndicator) {
47154
+ bindSourceFileAsExternalModule();
47155
+ }
47145
47156
  }
47146
47157
  return true;
47147
47158
  }
@@ -47555,7 +47566,11 @@ var ts;
47555
47566
  checkStrictModeEvalOrArguments(node, node.name);
47556
47567
  }
47557
47568
  if (!ts.isBindingPattern(node.name)) {
47558
- if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47569
+ var possibleVariableDecl = node.kind === 254 /* VariableDeclaration */ ? node : node.parent.parent;
47570
+ if (ts.isInJSFile(node) &&
47571
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
47572
+ !ts.getJSDocTypeTag(node) &&
47573
+ !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47559
47574
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
47560
47575
  }
47561
47576
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -48732,6 +48747,7 @@ var ts;
48732
48747
  var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
48733
48748
  emptyTypeLiteralSymbol.members = ts.createSymbolTable();
48734
48749
  var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
48750
+ var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType;
48735
48751
  var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
48736
48752
  emptyGenericType.instantiations = new ts.Map();
48737
48753
  var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
@@ -50382,7 +50398,8 @@ var ts;
50382
50398
  && isAliasableOrJsExpression(node.parent.right)
50383
50399
  || node.kind === 297 /* ShorthandPropertyAssignment */
50384
50400
  || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
50385
- || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
50401
+ || node.kind === 254 /* VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
50402
+ || node.kind === 203 /* BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
50386
50403
  }
50387
50404
  function isAliasableOrJsExpression(e) {
50388
50405
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -50475,7 +50492,7 @@ var ts;
50475
50492
  return hasExportAssignmentSymbol(moduleSymbol);
50476
50493
  }
50477
50494
  // JS files have a synthetic default if they do not contain ES2015+ module syntax (export = is not valid in js) _and_ do not have an __esModule marker
50478
- return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50495
+ return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50479
50496
  }
50480
50497
  function getTargetOfImportClause(node, dontResolveAlias) {
50481
50498
  var _a;
@@ -58901,7 +58918,7 @@ var ts;
58901
58918
  }
58902
58919
  }
58903
58920
  }
58904
- else if (t.flags & 469892092 /* DisjointDomains */) {
58921
+ else if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
58905
58922
  hasDisjointDomainType = true;
58906
58923
  }
58907
58924
  }
@@ -58913,7 +58930,7 @@ var ts;
58913
58930
  // intersection operation to reduce the union constraints.
58914
58931
  for (var _a = 0, types_6 = types; _a < types_6.length; _a++) {
58915
58932
  var t = types_6[_a];
58916
- if (t.flags & 469892092 /* DisjointDomains */) {
58933
+ if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
58917
58934
  constraints = ts.append(constraints, t);
58918
58935
  }
58919
58936
  }
@@ -61462,7 +61479,7 @@ var ts;
61462
61479
  }
61463
61480
  return includes;
61464
61481
  }
61465
- function removeRedundantPrimitiveTypes(types, includes) {
61482
+ function removeRedundantSupertypes(types, includes) {
61466
61483
  var i = types.length;
61467
61484
  while (i > 0) {
61468
61485
  i--;
@@ -61470,7 +61487,9 @@ var ts;
61470
61487
  var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61471
61488
  t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61472
61489
  t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61473
- t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */;
61490
+ t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
61491
+ t.flags & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
61492
+ isEmptyAnonymousObjectType(t) && includes & 470302716 /* DefinitelyNonNullable */;
61474
61493
  if (remove) {
61475
61494
  ts.orderedRemoveItemAt(types, i);
61476
61495
  }
@@ -61592,7 +61611,7 @@ var ts;
61592
61611
  // a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
61593
61612
  // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
61594
61613
  // for intersections of types with signatures can be deterministic.
61595
- function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
61614
+ function getIntersectionType(types, aliasSymbol, aliasTypeArguments, noSupertypeReduction) {
61596
61615
  var typeMembershipMap = new ts.Map();
61597
61616
  var includes = addTypesToIntersection(typeMembershipMap, 0, types);
61598
61617
  var typeSet = ts.arrayFrom(typeMembershipMap.values());
@@ -61629,11 +61648,11 @@ var ts;
61629
61648
  if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61630
61649
  includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61631
61650
  includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61632
- includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) {
61633
- removeRedundantPrimitiveTypes(typeSet, includes);
61634
- }
61635
- if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) {
61636
- ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
61651
+ includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
61652
+ includes & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
61653
+ includes & 16777216 /* IncludesEmptyObject */ && includes & 470302716 /* DefinitelyNonNullable */) {
61654
+ if (!noSupertypeReduction)
61655
+ removeRedundantSupertypes(typeSet, includes);
61637
61656
  }
61638
61657
  if (includes & 262144 /* IncludesMissingType */) {
61639
61658
  typeSet[typeSet.indexOf(undefinedType)] = missingType;
@@ -61672,8 +61691,9 @@ var ts;
61672
61691
  }
61673
61692
  var constituents = getCrossProductIntersections(typeSet);
61674
61693
  // We attach a denormalized origin type when at least one constituent of the cross-product union is an
61675
- // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions).
61676
- var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
61694
+ // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions) and
61695
+ // the denormalized origin has fewer constituents than the union itself.
61696
+ var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
61677
61697
  result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
61678
61698
  }
61679
61699
  }
@@ -61716,11 +61736,21 @@ var ts;
61716
61736
  }
61717
61737
  return intersections;
61718
61738
  }
61739
+ function getConstituentCount(type) {
61740
+ return !(type.flags & 3145728 /* UnionOrIntersection */) || type.aliasSymbol ? 1 :
61741
+ type.flags & 1048576 /* Union */ && type.origin ? getConstituentCount(type.origin) :
61742
+ getConstituentCountOfTypes(type.types);
61743
+ }
61744
+ function getConstituentCountOfTypes(types) {
61745
+ return ts.reduceLeft(types, function (n, t) { return n + getConstituentCount(t); }, 0);
61746
+ }
61719
61747
  function getTypeFromIntersectionTypeNode(node) {
61720
61748
  var links = getNodeLinks(node);
61721
61749
  if (!links.resolvedType) {
61722
61750
  var aliasSymbol = getAliasSymbolForTypeNode(node);
61723
- links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
61751
+ var types = ts.map(node.types, getTypeFromTypeNode);
61752
+ var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) && types[1] === emptyTypeLiteralType;
61753
+ links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction);
61724
61754
  }
61725
61755
  return links.resolvedType;
61726
61756
  }
@@ -64506,6 +64536,17 @@ var ts;
64506
64536
  return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) ||
64507
64537
  type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0));
64508
64538
  }
64539
+ function isUnknownLikeUnionType(type) {
64540
+ if (strictNullChecks && type.flags & 1048576 /* Union */) {
64541
+ if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) {
64542
+ var types = type.types;
64543
+ type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* Undefined */ &&
64544
+ types[1].flags & 65536 /* Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0);
64545
+ }
64546
+ return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */);
64547
+ }
64548
+ return false;
64549
+ }
64509
64550
  function isStringIndexSignatureOnlyType(type) {
64510
64551
  return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) ||
64511
64552
  type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) ||
@@ -64585,7 +64626,7 @@ var ts;
64585
64626
  return true;
64586
64627
  if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
64587
64628
  return true;
64588
- if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */)
64629
+ if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source)))
64589
64630
  return true;
64590
64631
  if (relation === assignableRelation || relation === comparableRelation) {
64591
64632
  if (s & 1 /* Any */)
@@ -64595,6 +64636,9 @@ var ts;
64595
64636
  // bit-flag enum types sometimes look like literal enum types with numeric literal values.
64596
64637
  if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */))
64597
64638
  return true;
64639
+ // Anything is assignable to a union containing undefined, null, and {}
64640
+ if (isUnknownLikeUnionType(target))
64641
+ return true;
64598
64642
  }
64599
64643
  return false;
64600
64644
  }
@@ -64637,16 +64681,27 @@ var ts;
64637
64681
  function getNormalizedType(type, writing) {
64638
64682
  while (true) {
64639
64683
  var t = isFreshLiteralType(type) ? type.regularType :
64640
- ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) :
64641
- type.flags & 3145728 /* UnionOrIntersection */ ? getReducedType(type) :
64684
+ ts.getObjectFlags(type) & 4 /* Reference */ ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type :
64685
+ type.flags & 3145728 /* UnionOrIntersection */ ? getNormalizedUnionOrIntersectionType(type, writing) :
64642
64686
  type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute :
64643
64687
  type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) :
64644
64688
  type;
64645
- t = getSingleBaseForNonAugmentingSubtype(t) || t;
64646
64689
  if (t === type)
64647
- break;
64690
+ return t;
64648
64691
  type = t;
64649
64692
  }
64693
+ }
64694
+ function getNormalizedUnionOrIntersectionType(type, writing) {
64695
+ var reduced = getReducedType(type);
64696
+ if (reduced !== type) {
64697
+ return reduced;
64698
+ }
64699
+ if (type.flags & 2097152 /* Intersection */) {
64700
+ var normalizedTypes = ts.sameMap(type.types, function (t) { return getNormalizedType(t, writing); });
64701
+ if (normalizedTypes !== type.types) {
64702
+ return getIntersectionType(normalizedTypes);
64703
+ }
64704
+ }
64650
64705
  return type;
64651
64706
  }
64652
64707
  /**
@@ -65093,6 +65148,7 @@ var ts;
65093
65148
  return 0 /* False */;
65094
65149
  }
65095
65150
  function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
65151
+ var _a, _b;
65096
65152
  var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
65097
65153
  var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
65098
65154
  source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
@@ -65133,6 +65189,9 @@ var ts;
65133
65189
  return;
65134
65190
  }
65135
65191
  reportRelationError(headMessage, source, target);
65192
+ if (strictNullChecks && source.flags & 8650752 /* TypeVariable */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source) && isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) {
65193
+ associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint));
65194
+ }
65136
65195
  }
65137
65196
  function traceUnionsOrIntersectionsTooLarge(source, target) {
65138
65197
  if (!ts.tracing) {
@@ -65919,13 +65978,6 @@ var ts;
65919
65978
  // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
65920
65979
  if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
65921
65980
  var constraint = getConstraintOfType(source) || unknownType;
65922
- if (!getConstraintOfType(source) || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
65923
- // A type variable with no constraint is not related to the non-primitive object type.
65924
- if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
65925
- resetErrorInfo(saveErrorInfo);
65926
- return result;
65927
- }
65928
- }
65929
65981
  // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed
65930
65982
  if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
65931
65983
  resetErrorInfo(saveErrorInfo);
@@ -67399,9 +67451,11 @@ var ts;
67399
67451
  return getSupertypeOrUnion(types);
67400
67452
  }
67401
67453
  var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); });
67402
- return primaryTypes.length ?
67403
- getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* Nullable */) :
67404
- getUnionType(types, 2 /* Subtype */);
67454
+ if (primaryTypes.length) {
67455
+ var supertypeOrUnion = getSupertypeOrUnion(primaryTypes);
67456
+ return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true));
67457
+ }
67458
+ return getUnionType(types, 2 /* Subtype */);
67405
67459
  }
67406
67460
  // Return the leftmost type for which no type to the right is a subtype.
67407
67461
  function getCommonSubtype(types) {
@@ -67600,12 +67654,13 @@ var ts;
67600
67654
  // flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns
67601
67655
  // no flags for all other types (including non-falsy literal types).
67602
67656
  function getFalsyFlags(type) {
67603
- return type.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(type.types) :
67604
- type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 :
67605
- type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 :
67606
- type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 :
67607
- type.flags & 512 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* BooleanLiteral */ : 0 :
67608
- type.flags & 117724 /* PossiblyFalsy */;
67657
+ var t = type.flags & 2097152 /* Intersection */ ? getBaseConstraintOrType(type) : type;
67658
+ return t.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(t.types) :
67659
+ t.flags & 128 /* StringLiteral */ ? t.value === "" ? 128 /* StringLiteral */ : 0 :
67660
+ t.flags & 256 /* NumberLiteral */ ? t.value === 0 ? 256 /* NumberLiteral */ : 0 :
67661
+ t.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(t) ? 2048 /* BigIntLiteral */ : 0 :
67662
+ t.flags & 512 /* BooleanLiteral */ ? (t === falseType || t === regularFalseType) ? 512 /* BooleanLiteral */ : 0 :
67663
+ t.flags & 117724 /* PossiblyFalsy */;
67609
67664
  }
67610
67665
  function removeDefinitelyFalsyTypes(type) {
67611
67666
  return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ?
@@ -67645,20 +67700,22 @@ var ts;
67645
67700
  return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]);
67646
67701
  }
67647
67702
  function getGlobalNonNullableTypeInstantiation(type) {
67648
- // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
67649
- // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
67650
- // that isn't eliminated by a NonNullable<T> instantiation.
67651
- var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
67652
67703
  if (!deferredGlobalNonNullableTypeAlias) {
67653
67704
  deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol;
67654
67705
  }
67655
- // If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
67656
67706
  return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
67657
- getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
67658
- reducedType;
67707
+ getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]) :
67708
+ getIntersectionType([type, emptyObjectType]);
67659
67709
  }
67660
67710
  function getNonNullableType(type) {
67661
- return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
67711
+ if (strictNullChecks) {
67712
+ // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
67713
+ // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
67714
+ // that isn't eliminated by a NonNullable<T> instantiation.
67715
+ var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
67716
+ return maybeTypeOfKind(reducedType, 465829888 /* Instantiable */) ? getGlobalNonNullableTypeInstantiation(reducedType) : reducedType;
67717
+ }
67718
+ return type;
67662
67719
  }
67663
67720
  function addOptionalTypeMarker(type) {
67664
67721
  return strictNullChecks ? getUnionType([type, optionalType]) : type;
@@ -68339,13 +68396,40 @@ var ts;
68339
68396
  return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
68340
68397
  sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
68341
68398
  }
68342
- function isValidBigIntString(s) {
68399
+ /**
68400
+ * Tests whether the provided string can be parsed as a number.
68401
+ * @param s The string to test.
68402
+ * @param roundTripOnly Indicates the resulting number matches the input when converted back to a string.
68403
+ */
68404
+ function isValidNumberString(s, roundTripOnly) {
68405
+ if (s === "")
68406
+ return false;
68407
+ var n = +s;
68408
+ return isFinite(n) && (!roundTripOnly || "" + n === s);
68409
+ }
68410
+ /**
68411
+ * @param text a valid bigint string excluding a trailing `n`, but including a possible prefix `-`. Use `isValidBigIntString(text, roundTripOnly)` before calling this function.
68412
+ */
68413
+ function parseBigIntLiteralType(text) {
68414
+ var negative = text.startsWith("-");
68415
+ var base10Value = ts.parsePseudoBigInt((negative ? text.slice(1) : text) + "n");
68416
+ return getBigIntLiteralType({ negative: negative, base10Value: base10Value });
68417
+ }
68418
+ /**
68419
+ * Tests whether the provided string can be parsed as a bigint.
68420
+ * @param s The string to test.
68421
+ * @param roundTripOnly Indicates the resulting bigint matches the input when converted back to a string.
68422
+ */
68423
+ function isValidBigIntString(s, roundTripOnly) {
68424
+ if (s === "")
68425
+ return false;
68343
68426
  var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false);
68344
68427
  var success = true;
68345
68428
  scanner.setOnError(function () { return success = false; });
68346
68429
  scanner.setText(s + "n");
68347
68430
  var result = scanner.scan();
68348
- if (result === 40 /* MinusToken */) {
68431
+ var negative = result === 40 /* MinusToken */;
68432
+ if (negative) {
68349
68433
  result = scanner.scan();
68350
68434
  }
68351
68435
  var flags = scanner.getTokenFlags();
@@ -68354,7 +68438,8 @@ var ts;
68354
68438
  // * a bigint can be scanned, and that when it is scanned, it is
68355
68439
  // * the full length of the input string (so the scanner is one character beyond the augmented input length)
68356
68440
  // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input)
68357
- return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */);
68441
+ return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
68442
+ && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
68358
68443
  }
68359
68444
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
68360
68445
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
@@ -68362,8 +68447,8 @@ var ts;
68362
68447
  }
68363
68448
  if (source.flags & 128 /* StringLiteral */) {
68364
68449
  var value = source.value;
68365
- return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) ||
68366
- target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) ||
68450
+ return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
68451
+ target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
68367
68452
  target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
68368
68453
  }
68369
68454
  if (source.flags & 134217728 /* TemplateLiteral */) {
@@ -68936,8 +69021,57 @@ var ts;
68936
69021
  // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
68937
69022
  // succeed. That would be a pointless and confusing outcome.
68938
69023
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
69024
+ var _loop_23 = function (i) {
69025
+ var source_1 = matches ? matches[i] : neverType;
69026
+ var target_3 = types[i];
69027
+ // If we are inferring from a string literal type to a type variable whose constraint includes one of the
69028
+ // allowed template literal placeholder types, infer from a literal type corresponding to the constraint.
69029
+ if (source_1.flags & 128 /* StringLiteral */ && target_3.flags & 8650752 /* TypeVariable */) {
69030
+ var inferenceContext = getInferenceInfoForType(target_3);
69031
+ var constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : undefined;
69032
+ if (constraint && !isTypeAny(constraint)) {
69033
+ var constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint];
69034
+ var allTypeFlags_1 = ts.reduceLeft(constraintTypes, function (flags, t) { return flags | t.flags; }, 0);
69035
+ // If the constraint contains `string`, we don't need to look for a more preferred type
69036
+ if (!(allTypeFlags_1 & 4 /* String */)) {
69037
+ var str_1 = source_1.value;
69038
+ // If the type contains `number` or a number literal and the string isn't a valid number, exclude numbers
69039
+ if (allTypeFlags_1 & 296 /* NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) {
69040
+ allTypeFlags_1 &= ~296 /* NumberLike */;
69041
+ }
69042
+ // If the type contains `bigint` or a bigint literal and the string isn't a valid bigint, exclude bigints
69043
+ if (allTypeFlags_1 & 2112 /* BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) {
69044
+ allTypeFlags_1 &= ~2112 /* BigIntLike */;
69045
+ }
69046
+ // for each type in the constraint, find the highest priority matching type
69047
+ var matchingType = ts.reduceLeft(constraintTypes, function (left, right) {
69048
+ return !(right.flags & allTypeFlags_1) ? left :
69049
+ left.flags & 4 /* String */ ? left : right.flags & 4 /* String */ ? source_1 :
69050
+ left.flags & 134217728 /* TemplateLiteral */ ? left : right.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 :
69051
+ left.flags & 268435456 /* StringMapping */ ? left : right.flags & 268435456 /* StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 :
69052
+ left.flags & 128 /* StringLiteral */ ? left : right.flags & 128 /* StringLiteral */ && right.value === str_1 ? right :
69053
+ left.flags & 8 /* Number */ ? left : right.flags & 8 /* Number */ ? getNumberLiteralType(+str_1) :
69054
+ left.flags & 32 /* Enum */ ? left : right.flags & 32 /* Enum */ ? getNumberLiteralType(+str_1) :
69055
+ left.flags & 256 /* NumberLiteral */ ? left : right.flags & 256 /* NumberLiteral */ && right.value === +str_1 ? right :
69056
+ left.flags & 64 /* BigInt */ ? left : right.flags & 64 /* BigInt */ ? parseBigIntLiteralType(str_1) :
69057
+ left.flags & 2048 /* BigIntLiteral */ ? left : right.flags & 2048 /* BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right :
69058
+ left.flags & 16 /* Boolean */ ? left : right.flags & 16 /* Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType :
69059
+ left.flags & 512 /* BooleanLiteral */ ? left : right.flags & 512 /* BooleanLiteral */ && right.intrinsicName === str_1 ? right :
69060
+ left.flags & 32768 /* Undefined */ ? left : right.flags & 32768 /* Undefined */ && right.intrinsicName === str_1 ? right :
69061
+ left.flags & 65536 /* Null */ ? left : right.flags & 65536 /* Null */ && right.intrinsicName === str_1 ? right :
69062
+ left;
69063
+ }, neverType);
69064
+ if (!(matchingType.flags & 131072 /* Never */)) {
69065
+ inferFromTypes(matchingType, target_3);
69066
+ return "continue";
69067
+ }
69068
+ }
69069
+ }
69070
+ }
69071
+ inferFromTypes(source_1, target_3);
69072
+ };
68939
69073
  for (var i = 0; i < types.length; i++) {
68940
- inferFromTypes(matches ? matches[i] : neverType, types[i]);
69074
+ _loop_23(i);
68941
69075
  }
68942
69076
  }
68943
69077
  }
@@ -69455,7 +69589,7 @@ var ts;
69455
69589
  function mapTypesByKeyProperty(types, name) {
69456
69590
  var map = new ts.Map();
69457
69591
  var count = 0;
69458
- var _loop_23 = function (type) {
69592
+ var _loop_24 = function (type) {
69459
69593
  if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
69460
69594
  var discriminant = getTypeOfPropertyOfType(type, name);
69461
69595
  if (discriminant) {
@@ -69481,7 +69615,7 @@ var ts;
69481
69615
  };
69482
69616
  for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
69483
69617
  var type = types_16[_i];
69484
- var state_9 = _loop_23(type);
69618
+ var state_9 = _loop_24(type);
69485
69619
  if (typeof state_9 === "object")
69486
69620
  return state_9.value;
69487
69621
  }
@@ -69689,6 +69823,24 @@ var ts;
69689
69823
  function getTypeWithFacts(type, include) {
69690
69824
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
69691
69825
  }
69826
+ function getIntersectionWithFacts(type, facts) {
69827
+ var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
69828
+ if (strictNullChecks) {
69829
+ switch (facts) {
69830
+ case 524288 /* NEUndefined */:
69831
+ return mapType(reduced, function (t) { return getTypeFacts(t) & 65536 /* EQUndefined */ ? getIntersectionType([t, getTypeFacts(t) & 131072 /* EQNull */ && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t; });
69832
+ case 1048576 /* NENull */:
69833
+ return mapType(reduced, function (t) { return getTypeFacts(t) & 131072 /* EQNull */ ? getIntersectionType([t, getTypeFacts(t) & 65536 /* EQUndefined */ && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t; });
69834
+ case 2097152 /* NEUndefinedOrNull */:
69835
+ case 4194304 /* Truthy */:
69836
+ return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; });
69837
+ }
69838
+ }
69839
+ return reduced;
69840
+ }
69841
+ function recombineUnknownType(type) {
69842
+ return type === unknownUnionType ? unknownType : type;
69843
+ }
69692
69844
  function getTypeWithDefault(type, defaultExpression) {
69693
69845
  return defaultExpression ?
69694
69846
  getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) :
@@ -70746,7 +70898,7 @@ var ts;
70746
70898
  if (isEvolvingArrayTypeList(types)) {
70747
70899
  return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType)));
70748
70900
  }
70749
- var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction);
70901
+ var result = recombineUnknownType(getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction));
70750
70902
  if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) {
70751
70903
  return declaredType;
70752
70904
  }
@@ -70848,8 +71000,7 @@ var ts;
70848
71000
  }
70849
71001
  function narrowTypeByTruthiness(type, expr, assumeTrue) {
70850
71002
  if (isMatchingReference(reference, expr)) {
70851
- return type.flags & 2 /* Unknown */ && assumeTrue ? nonNullUnknownType :
70852
- getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
71003
+ return getIntersectionWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
70853
71004
  }
70854
71005
  if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
70855
71006
  type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
@@ -71002,9 +71153,6 @@ var ts;
71002
71153
  assumeTrue = !assumeTrue;
71003
71154
  }
71004
71155
  var valueType = getTypeOfExpression(value);
71005
- if (assumeTrue && (type.flags & 2 /* Unknown */) && (operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */) && (valueType.flags & 65536 /* Null */)) {
71006
- return getUnionType([nullType, undefinedType]);
71007
- }
71008
71156
  if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) {
71009
71157
  if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) {
71010
71158
  return valueType;
@@ -71024,7 +71172,7 @@ var ts;
71024
71172
  valueType.flags & 65536 /* Null */ ?
71025
71173
  assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ :
71026
71174
  assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */;
71027
- return type.flags & 2 /* Unknown */ && facts & (1048576 /* NENull */ | 2097152 /* NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts);
71175
+ return getIntersectionWithFacts(type, facts);
71028
71176
  }
71029
71177
  if (assumeTrue) {
71030
71178
  var filterFn = operator === 34 /* EqualsEqualsToken */ ?
@@ -71052,17 +71200,11 @@ var ts;
71052
71200
  if (type.flags & 1 /* Any */ && literal.text === "function") {
71053
71201
  return type;
71054
71202
  }
71055
- if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") {
71056
- // The non-null unknown type is used to track whether a previous narrowing operation has removed the null type
71057
- // from the unknown type. For example, the expression `x && typeof x === 'object'` first narrows x to the non-null
71058
- // unknown type, and then narrows that to the non-primitive type.
71059
- return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]);
71060
- }
71061
71203
  var facts = assumeTrue ?
71062
71204
  typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ :
71063
71205
  typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */;
71064
71206
  var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
71065
- return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts);
71207
+ return getTypeWithFacts(assumeTrue && impliedType ? narrowTypeByImpliedType(type, impliedType) : type, facts);
71066
71208
  }
71067
71209
  function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
71068
71210
  var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
@@ -71111,10 +71253,10 @@ var ts;
71111
71253
  }
71112
71254
  function getImpliedTypeFromTypeofGuard(type, text) {
71113
71255
  switch (text) {
71256
+ case "object":
71257
+ return type.flags & 1 /* Any */ ? type : getUnionType([nullType, nonPrimitiveType]);
71114
71258
  case "function":
71115
71259
  return type.flags & 1 /* Any */ ? type : globalFunctionType;
71116
- case "object":
71117
- return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type;
71118
71260
  default:
71119
71261
  return typeofTypesByName.get(text);
71120
71262
  }
@@ -71125,22 +71267,27 @@ var ts;
71125
71267
  // the guard. For example: narrowing `{} | undefined` by `"boolean"` should produce the type `boolean`, not
71126
71268
  // the filtered type `{}`. For this reason we narrow constituents of the union individually, in addition to
71127
71269
  // filtering by type-facts.
71128
- function narrowUnionMemberByTypeof(candidate) {
71129
- return function (type) {
71130
- if (isTypeSubtypeOf(type, candidate)) {
71131
- return type;
71132
- }
71133
- if (isTypeSubtypeOf(candidate, type)) {
71134
- return candidate;
71270
+ function narrowTypeByImpliedType(type, candidate) {
71271
+ if (type.flags & 3 /* AnyOrUnknown */) {
71272
+ return candidate;
71273
+ }
71274
+ return mapType(type, function (t) {
71275
+ if (isTypeRelatedTo(t, candidate, strictSubtypeRelation)) {
71276
+ return t;
71135
71277
  }
71136
- if (type.flags & 465829888 /* Instantiable */) {
71137
- var constraint = getBaseConstraintOfType(type) || anyType;
71138
- if (isTypeSubtypeOf(candidate, constraint)) {
71139
- return getIntersectionType([type, candidate]);
71278
+ return mapType(candidate, function (c) {
71279
+ if (!areTypesComparable(t, c)) {
71280
+ return neverType;
71140
71281
  }
71141
- }
71142
- return type;
71143
- };
71282
+ if (c.flags & 131068 /* Primitive */ && t.flags & 524288 /* Object */ && !isEmptyAnonymousObjectType(t)) {
71283
+ return isTypeSubtypeOf(c, t) ? c : neverType;
71284
+ }
71285
+ if (c === globalFunctionType && isTypeSubtypeOf(c, t)) {
71286
+ return c;
71287
+ }
71288
+ return getIntersectionType([t, c]);
71289
+ });
71290
+ });
71144
71291
  }
71145
71292
  function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
71146
71293
  var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, /*retainDefault*/ true);
@@ -71199,7 +71346,7 @@ var ts;
71199
71346
  because it is caught in the first clause.
71200
71347
  */
71201
71348
  var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
71202
- return getTypeWithFacts(mapType(type, narrowUnionMemberByTypeof(impliedType)), switchFacts);
71349
+ return getTypeWithFacts(narrowTypeByImpliedType(type, impliedType), switchFacts);
71203
71350
  }
71204
71351
  function isMatchingConstructorReference(expr) {
71205
71352
  return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
@@ -71503,7 +71650,9 @@ var ts;
71503
71650
  !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
71504
71651
  }
71505
71652
  function isGenericTypeWithUnionConstraint(type) {
71506
- return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
71653
+ return type.flags & 2097152 /* Intersection */ ?
71654
+ ts.some(type.types, isGenericTypeWithUnionConstraint) :
71655
+ !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
71507
71656
  }
71508
71657
  function isGenericTypeWithoutNullableConstraint(type) {
71509
71658
  return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
@@ -71531,7 +71680,7 @@ var ts;
71531
71680
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
71532
71681
  someType(type, isGenericTypeWithUnionConstraint) &&
71533
71682
  (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
71534
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
71683
+ return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
71535
71684
  }
71536
71685
  function isExportOrExportExpression(location) {
71537
71686
  return !!ts.findAncestor(location, function (n) {
@@ -75869,7 +76018,7 @@ var ts;
75869
76018
  if (spreadIndex >= 0) {
75870
76019
  // Create synthetic arguments from spreads of tuple types.
75871
76020
  var effectiveArgs_1 = args.slice(0, spreadIndex);
75872
- var _loop_24 = function (i) {
76021
+ var _loop_25 = function (i) {
75873
76022
  var arg = args[i];
75874
76023
  // We can call checkExpressionCached because spread expressions never have a contextual type.
75875
76024
  var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -75886,7 +76035,7 @@ var ts;
75886
76035
  }
75887
76036
  };
75888
76037
  for (var i = spreadIndex; i < args.length; i++) {
75889
- _loop_24(i);
76038
+ _loop_25(i);
75890
76039
  }
75891
76040
  return effectiveArgs_1;
75892
76041
  }
@@ -76206,7 +76355,7 @@ var ts;
76206
76355
  var min_3 = Number.MAX_VALUE;
76207
76356
  var minIndex = 0;
76208
76357
  var i_1 = 0;
76209
- var _loop_25 = function (c) {
76358
+ var _loop_26 = function (c) {
76210
76359
  var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
76211
76360
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
76212
76361
  if (diags_2) {
@@ -76224,7 +76373,7 @@ var ts;
76224
76373
  };
76225
76374
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
76226
76375
  var c = candidatesForArgumentError_1[_a];
76227
- _loop_25(c);
76376
+ _loop_26(c);
76228
76377
  }
76229
76378
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
76230
76379
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -76382,7 +76531,7 @@ var ts;
76382
76531
  }
76383
76532
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
76384
76533
  var parameters = [];
76385
- var _loop_26 = function (i) {
76534
+ var _loop_27 = function (i) {
76386
76535
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
76387
76536
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
76388
76537
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -76390,7 +76539,7 @@ var ts;
76390
76539
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
76391
76540
  };
76392
76541
  for (var i = 0; i < maxNonRestParam; i++) {
76393
- _loop_26(i);
76542
+ _loop_27(i);
76394
76543
  }
76395
76544
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
76396
76545
  var flags = 0 /* None */;
@@ -80447,7 +80596,7 @@ var ts;
80447
80596
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
80448
80597
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
80449
80598
  var indexSignatureMap_1 = new ts.Map();
80450
- var _loop_27 = function (declaration) {
80599
+ var _loop_28 = function (declaration) {
80451
80600
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
80452
80601
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
80453
80602
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -80462,7 +80611,7 @@ var ts;
80462
80611
  };
80463
80612
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
80464
80613
  var declaration = _a[_i];
80465
- _loop_27(declaration);
80614
+ _loop_28(declaration);
80466
80615
  }
80467
80616
  indexSignatureMap_1.forEach(function (entry) {
80468
80617
  if (entry.declarations.length > 1) {
@@ -82658,7 +82807,7 @@ var ts;
82658
82807
  }
82659
82808
  // For a commonjs `const x = require`, validate the alias and exit
82660
82809
  var symbol = getSymbolOfNode(node);
82661
- if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
82810
+ if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* BindingElement */ ? node.parent.parent : node)) {
82662
82811
  checkAliasSymbol(node);
82663
82812
  return;
82664
82813
  }
@@ -83923,7 +84072,7 @@ var ts;
83923
84072
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
83924
84073
  var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ ||
83925
84074
  name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
83926
- var _loop_28 = function (info) {
84075
+ var _loop_29 = function (info) {
83927
84076
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
83928
84077
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
83929
84078
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -83936,7 +84085,7 @@ var ts;
83936
84085
  };
83937
84086
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
83938
84087
  var info = indexInfos_9[_i];
83939
- _loop_28(info);
84088
+ _loop_29(info);
83940
84089
  }
83941
84090
  }
83942
84091
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -83944,7 +84093,7 @@ var ts;
83944
84093
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
83945
84094
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
83946
84095
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
83947
- var _loop_29 = function (info) {
84096
+ var _loop_30 = function (info) {
83948
84097
  if (info === checkInfo)
83949
84098
  return "continue";
83950
84099
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -83959,7 +84108,7 @@ var ts;
83959
84108
  };
83960
84109
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
83961
84110
  var info = indexInfos_10[_i];
83962
- _loop_29(info);
84111
+ _loop_30(info);
83963
84112
  }
83964
84113
  }
83965
84114
  function checkTypeNameIsReserved(name, message) {
@@ -84278,7 +84427,7 @@ var ts;
84278
84427
  var baseTypes = baseTypeNode && getBaseTypes(type);
84279
84428
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
84280
84429
  var baseStaticType = getBaseConstructorTypeOfClass(type);
84281
- var _loop_30 = function (member) {
84430
+ var _loop_31 = function (member) {
84282
84431
  if (ts.hasAmbientModifier(member)) {
84283
84432
  return "continue";
84284
84433
  }
@@ -84295,7 +84444,7 @@ var ts;
84295
84444
  };
84296
84445
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84297
84446
  var member = _a[_i];
84298
- _loop_30(member);
84447
+ _loop_31(member);
84299
84448
  }
84300
84449
  }
84301
84450
  /**
@@ -84383,7 +84532,7 @@ var ts;
84383
84532
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
84384
84533
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
84385
84534
  var issuedMemberError = false;
84386
- var _loop_31 = function (member) {
84535
+ var _loop_32 = function (member) {
84387
84536
  if (ts.isStatic(member)) {
84388
84537
  return "continue";
84389
84538
  }
@@ -84402,7 +84551,7 @@ var ts;
84402
84551
  };
84403
84552
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84404
84553
  var member = _a[_i];
84405
- _loop_31(member);
84554
+ _loop_32(member);
84406
84555
  }
84407
84556
  if (!issuedMemberError) {
84408
84557
  // check again with diagnostics to generate a less-specific error
@@ -122370,7 +122519,7 @@ var ts;
122370
122519
  });
122371
122520
  // Sort by paths closest to importing file Name directory
122372
122521
  var sortedPaths = [];
122373
- var _loop_32 = function (directory) {
122522
+ var _loop_33 = function (directory) {
122374
122523
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
122375
122524
  var pathsInDirectory;
122376
122525
  allFileNames.forEach(function (_a, fileName) {
@@ -122394,7 +122543,7 @@ var ts;
122394
122543
  };
122395
122544
  var out_directory_1;
122396
122545
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
122397
- var state_10 = _loop_32(directory);
122546
+ var state_10 = _loop_33(directory);
122398
122547
  directory = out_directory_1;
122399
122548
  if (state_10 === "break")
122400
122549
  break;
@@ -123841,6 +123990,7 @@ var ts;
123841
123990
  }
123842
123991
  function reloadFileNamesFromConfigFile() {
123843
123992
  writeLog("Reloading new file names and options");
123993
+ reloadLevel = ts.ConfigFileProgramReloadLevel.None;
123844
123994
  rootFileNames = ts.getFileNamesFromConfigSpecs(compilerOptions.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
123845
123995
  if (ts.updateErrorForNoInputFiles(rootFileNames, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile.configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
123846
123996
  hasChangedConfigFileParsingErrors = true;
@@ -136938,7 +137088,7 @@ var ts;
136938
137088
  ts.Debug.assert(parent.name === node);
136939
137089
  return true;
136940
137090
  case 203 /* BindingElement */:
136941
- return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
137091
+ return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent.parent.parent);
136942
137092
  default:
136943
137093
  return false;
136944
137094
  }
@@ -138404,7 +138554,7 @@ var ts;
138404
138554
  // Use the parent symbol if the location is commonjs require syntax on javascript files only.
138405
138555
  if (ts.isInJSFile(referenceLocation)
138406
138556
  && referenceLocation.parent.kind === 203 /* BindingElement */
138407
- && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
138557
+ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) {
138408
138558
  referenceSymbol = referenceLocation.parent.symbol;
138409
138559
  // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
138410
138560
  // this case, just skip it, since the bound identifiers are not an alias of the import.
@@ -144576,6 +144726,10 @@ var ts;
144576
144726
  }
144577
144727
  var typeDisplayString = printTypeInSingleLine(declarationType);
144578
144728
  if (typeDisplayString) {
144729
+ var isVariableNameMatchesType = preferences.includeInlayVariableTypeHintsWhenTypeMatchesName === false && ts.equateStringsCaseInsensitive(decl.name.getText(), typeDisplayString);
144730
+ if (isVariableNameMatchesType) {
144731
+ return;
144732
+ }
144579
144733
  addTypeHints(typeDisplayString, decl.name.end);
144580
144734
  }
144581
144735
  }
@@ -147776,11 +147930,9 @@ var ts;
147776
147930
  if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) {
147777
147931
  var tokenInfo = formattingScanner.readTokenInfo(parent);
147778
147932
  if (tokenInfo.token.kind === 27 /* CommaToken */ && ts.isCallLikeExpression(parent)) {
147779
- var commaTokenLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line;
147780
- if (startLine !== commaTokenLine) {
147781
- formattingScanner.advance();
147782
- tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined;
147783
- }
147933
+ // consume the comma
147934
+ consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent);
147935
+ tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined;
147784
147936
  }
147785
147937
  // consume the list end token only if it is still belong to the parent
147786
147938
  // there might be the case when current token matches end token but does not considered as one
@@ -175069,6 +175221,7 @@ var ts;
175069
175221
  return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
175070
175222
  }
175071
175223
  function getReferencesWorker(projects, defaultProject, initialLocation, logger) {
175224
+ var _a;
175072
175225
  var perProjectResults = getPerProjectReferences(projects, defaultProject, initialLocation,
175073
175226
  /*isForRename*/ false, function (project, position) {
175074
175227
  logger.info("Finding references to " + position.fileName + " position " + position.pos + " in project " + project.getProjectName());
@@ -175088,7 +175241,7 @@ var ts;
175088
175241
  // have started the other project searches from related symbols. Propagate the
175089
175242
  // correct results to all other projects.
175090
175243
  var defaultProjectResults = perProjectResults.get(defaultProject);
175091
- if (defaultProjectResults[0].references[0].isDefinition === undefined) {
175244
+ if (((_a = defaultProjectResults === null || defaultProjectResults === void 0 ? void 0 : defaultProjectResults[0].references[0]) === null || _a === void 0 ? void 0 : _a.isDefinition) === undefined) {
175092
175245
  // Clear all isDefinition properties
175093
175246
  perProjectResults.forEach(function (projectResults) {
175094
175247
  for (var _i = 0, projectResults_2 = projectResults; _i < projectResults_2.length; _i++) {
@@ -175105,8 +175258,8 @@ var ts;
175105
175258
  var knownSymbolSpans_1 = createDocumentSpanSet();
175106
175259
  for (var _i = 0, defaultProjectResults_1 = defaultProjectResults; _i < defaultProjectResults_1.length; _i++) {
175107
175260
  var referencedSymbol = defaultProjectResults_1[_i];
175108
- for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
175109
- var ref = _b[_a];
175261
+ for (var _b = 0, _c = referencedSymbol.references; _b < _c.length; _b++) {
175262
+ var ref = _c[_b];
175110
175263
  if (ref.isDefinition) {
175111
175264
  knownSymbolSpans_1.add(ref);
175112
175265
  // One is enough - updateIsDefinitionOfReferencedSymbols will fill out the set based on symbols
@@ -175266,11 +175419,9 @@ var ts;
175266
175419
  // it easier for the caller to skip post-processing.
175267
175420
  if (searchedProjects.size === 1) {
175268
175421
  var it = resultsMap.values().next();
175269
- ts.Debug.assert(!it.done);
175270
- return it.value;
175422
+ return it.done ? server.emptyArray : it.value; // There may not be any results at all
175271
175423
  }
175272
175424
  return resultsMap;
175273
- // May enqueue to otherPositionQueue
175274
175425
  function searchPosition(project, location) {
175275
175426
  var projectResults = getResultsForPosition(project, location);
175276
175427
  if (!projectResults)