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.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20220525";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220528";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -5101,6 +5101,11 @@ var ts;
5101
5101
  // Flags that require TypeFlags.Union
5102
5102
  /* @internal */
5103
5103
  ObjectFlags[ObjectFlags["ContainsIntersections"] = 16777216] = "ContainsIntersections";
5104
+ /* @internal */
5105
+ ObjectFlags[ObjectFlags["IsUnknownLikeUnionComputed"] = 33554432] = "IsUnknownLikeUnionComputed";
5106
+ /* @internal */
5107
+ ObjectFlags[ObjectFlags["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
5108
+ /* @internal */
5104
5109
  // Flags that require TypeFlags.Intersection
5105
5110
  /* @internal */
5106
5111
  ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 16777216] = "IsNeverIntersectionComputed";
@@ -8414,6 +8419,7 @@ var ts;
8414
8419
  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),
8415
8420
  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."),
8416
8421
  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."),
8422
+ 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."),
8417
8423
  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."),
8418
8424
  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."),
8419
8425
  Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
@@ -16218,9 +16224,6 @@ var ts;
16218
16224
  }
16219
16225
  ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
16220
16226
  function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
16221
- if (node.kind === 203 /* BindingElement */) {
16222
- node = node.parent.parent;
16223
- }
16224
16227
  return ts.isVariableDeclaration(node) &&
16225
16228
  !!node.initializer &&
16226
16229
  isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
@@ -20032,8 +20035,9 @@ var ts;
20032
20035
  */
20033
20036
  function isFileForcedToBeModuleByFormat(file) {
20034
20037
  // Excludes declaration files - they still require an explicit `export {}` or the like
20035
- // for back compat purposes.
20036
- return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
20038
+ // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
20039
+ // that aren't esm-mode (meaning not in a `type: module` scope).
20040
+ return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
20037
20041
  }
20038
20042
  function getSetExternalModuleIndicator(options) {
20039
20043
  // TODO: Should this callback be cached?
@@ -20041,7 +20045,7 @@ var ts;
20041
20045
  case ts.ModuleDetectionKind.Force:
20042
20046
  // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
20043
20047
  return function (file) {
20044
- file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
20048
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
20045
20049
  };
20046
20050
  case ts.ModuleDetectionKind.Legacy:
20047
20051
  // Files are modules if they have imports, exports, or import.meta
@@ -20101,7 +20105,8 @@ var ts;
20101
20105
  }
20102
20106
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
20103
20107
  function getEmitModuleDetectionKind(options) {
20104
- return options.moduleDetection || ts.ModuleDetectionKind.Auto;
20108
+ return options.moduleDetection ||
20109
+ (getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
20105
20110
  }
20106
20111
  ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
20107
20112
  function hasJsonModuleEmitEnabled(options) {
@@ -42043,7 +42048,7 @@ var ts;
42043
42048
  }
42044
42049
  if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
42045
42050
  return {
42046
- key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
42051
+ key: ts.removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec)),
42047
42052
  flags: 1 /* Recursive */
42048
42053
  };
42049
42054
  }
@@ -43148,16 +43153,20 @@ var ts;
43148
43153
  function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
43149
43154
  return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
43150
43155
  }
43156
+ var jsOnlyExtensions = [Extensions.JavaScript];
43157
+ var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
43158
+ var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
43159
+ var tsconfigExtensions = [Extensions.TSConfig];
43151
43160
  function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
43152
43161
  var containingDirectory = ts.getDirectoryPath(containingFile);
43153
43162
  // es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features
43154
43163
  var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
43155
- return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions, redirectedReference);
43164
+ var extensions = compilerOptions.noDtsResolution ? [Extensions.TsOnly, Extensions.JavaScript] : tsExtensions;
43165
+ if (compilerOptions.resolveJsonModule) {
43166
+ extensions = __spreadArray(__spreadArray([], extensions, true), [Extensions.Json], false);
43167
+ }
43168
+ return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference);
43156
43169
  }
43157
- var jsOnlyExtensions = [Extensions.JavaScript];
43158
- var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
43159
- var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
43160
- var tsconfigExtensions = [Extensions.TSConfig];
43161
43170
  function tryResolveJSModuleWorker(moduleName, initialDir, host) {
43162
43171
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
43163
43172
  }
@@ -46942,12 +46951,14 @@ var ts;
46942
46951
  }
46943
46952
  }
46944
46953
  function setCommonJsModuleIndicator(node) {
46945
- if (file.externalModuleIndicator) {
46954
+ if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
46946
46955
  return false;
46947
46956
  }
46948
46957
  if (!file.commonJsModuleIndicator) {
46949
46958
  file.commonJsModuleIndicator = node;
46950
- bindSourceFileAsExternalModule();
46959
+ if (!file.externalModuleIndicator) {
46960
+ bindSourceFileAsExternalModule();
46961
+ }
46951
46962
  }
46952
46963
  return true;
46953
46964
  }
@@ -47361,7 +47372,11 @@ var ts;
47361
47372
  checkStrictModeEvalOrArguments(node, node.name);
47362
47373
  }
47363
47374
  if (!ts.isBindingPattern(node.name)) {
47364
- if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47375
+ var possibleVariableDecl = node.kind === 254 /* VariableDeclaration */ ? node : node.parent.parent;
47376
+ if (ts.isInJSFile(node) &&
47377
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
47378
+ !ts.getJSDocTypeTag(node) &&
47379
+ !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47365
47380
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
47366
47381
  }
47367
47382
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -48538,6 +48553,7 @@ var ts;
48538
48553
  var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
48539
48554
  emptyTypeLiteralSymbol.members = ts.createSymbolTable();
48540
48555
  var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
48556
+ var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType;
48541
48557
  var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
48542
48558
  emptyGenericType.instantiations = new ts.Map();
48543
48559
  var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
@@ -50188,7 +50204,8 @@ var ts;
50188
50204
  && isAliasableOrJsExpression(node.parent.right)
50189
50205
  || node.kind === 297 /* ShorthandPropertyAssignment */
50190
50206
  || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
50191
- || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
50207
+ || node.kind === 254 /* VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
50208
+ || node.kind === 203 /* BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
50192
50209
  }
50193
50210
  function isAliasableOrJsExpression(e) {
50194
50211
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -50281,7 +50298,7 @@ var ts;
50281
50298
  return hasExportAssignmentSymbol(moduleSymbol);
50282
50299
  }
50283
50300
  // 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
50284
- return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50301
+ return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50285
50302
  }
50286
50303
  function getTargetOfImportClause(node, dontResolveAlias) {
50287
50304
  var _a;
@@ -58707,7 +58724,7 @@ var ts;
58707
58724
  }
58708
58725
  }
58709
58726
  }
58710
- else if (t.flags & 469892092 /* DisjointDomains */) {
58727
+ else if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
58711
58728
  hasDisjointDomainType = true;
58712
58729
  }
58713
58730
  }
@@ -58719,7 +58736,7 @@ var ts;
58719
58736
  // intersection operation to reduce the union constraints.
58720
58737
  for (var _a = 0, types_6 = types; _a < types_6.length; _a++) {
58721
58738
  var t = types_6[_a];
58722
- if (t.flags & 469892092 /* DisjointDomains */) {
58739
+ if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
58723
58740
  constraints = ts.append(constraints, t);
58724
58741
  }
58725
58742
  }
@@ -61268,7 +61285,7 @@ var ts;
61268
61285
  }
61269
61286
  return includes;
61270
61287
  }
61271
- function removeRedundantPrimitiveTypes(types, includes) {
61288
+ function removeRedundantSupertypes(types, includes) {
61272
61289
  var i = types.length;
61273
61290
  while (i > 0) {
61274
61291
  i--;
@@ -61276,7 +61293,9 @@ var ts;
61276
61293
  var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61277
61294
  t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61278
61295
  t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61279
- t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */;
61296
+ t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
61297
+ t.flags & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
61298
+ isEmptyAnonymousObjectType(t) && includes & 470302716 /* DefinitelyNonNullable */;
61280
61299
  if (remove) {
61281
61300
  ts.orderedRemoveItemAt(types, i);
61282
61301
  }
@@ -61398,7 +61417,7 @@ var ts;
61398
61417
  // a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
61399
61418
  // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
61400
61419
  // for intersections of types with signatures can be deterministic.
61401
- function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
61420
+ function getIntersectionType(types, aliasSymbol, aliasTypeArguments, noSupertypeReduction) {
61402
61421
  var typeMembershipMap = new ts.Map();
61403
61422
  var includes = addTypesToIntersection(typeMembershipMap, 0, types);
61404
61423
  var typeSet = ts.arrayFrom(typeMembershipMap.values());
@@ -61435,11 +61454,11 @@ var ts;
61435
61454
  if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61436
61455
  includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61437
61456
  includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61438
- includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) {
61439
- removeRedundantPrimitiveTypes(typeSet, includes);
61440
- }
61441
- if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) {
61442
- ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
61457
+ includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ ||
61458
+ includes & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
61459
+ includes & 16777216 /* IncludesEmptyObject */ && includes & 470302716 /* DefinitelyNonNullable */) {
61460
+ if (!noSupertypeReduction)
61461
+ removeRedundantSupertypes(typeSet, includes);
61443
61462
  }
61444
61463
  if (includes & 262144 /* IncludesMissingType */) {
61445
61464
  typeSet[typeSet.indexOf(undefinedType)] = missingType;
@@ -61478,8 +61497,9 @@ var ts;
61478
61497
  }
61479
61498
  var constituents = getCrossProductIntersections(typeSet);
61480
61499
  // We attach a denormalized origin type when at least one constituent of the cross-product union is an
61481
- // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions).
61482
- var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
61500
+ // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions) and
61501
+ // the denormalized origin has fewer constituents than the union itself.
61502
+ var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
61483
61503
  result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
61484
61504
  }
61485
61505
  }
@@ -61522,11 +61542,21 @@ var ts;
61522
61542
  }
61523
61543
  return intersections;
61524
61544
  }
61545
+ function getConstituentCount(type) {
61546
+ return !(type.flags & 3145728 /* UnionOrIntersection */) || type.aliasSymbol ? 1 :
61547
+ type.flags & 1048576 /* Union */ && type.origin ? getConstituentCount(type.origin) :
61548
+ getConstituentCountOfTypes(type.types);
61549
+ }
61550
+ function getConstituentCountOfTypes(types) {
61551
+ return ts.reduceLeft(types, function (n, t) { return n + getConstituentCount(t); }, 0);
61552
+ }
61525
61553
  function getTypeFromIntersectionTypeNode(node) {
61526
61554
  var links = getNodeLinks(node);
61527
61555
  if (!links.resolvedType) {
61528
61556
  var aliasSymbol = getAliasSymbolForTypeNode(node);
61529
- links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
61557
+ var types = ts.map(node.types, getTypeFromTypeNode);
61558
+ var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) && types[1] === emptyTypeLiteralType;
61559
+ links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction);
61530
61560
  }
61531
61561
  return links.resolvedType;
61532
61562
  }
@@ -64312,6 +64342,17 @@ var ts;
64312
64342
  return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) ||
64313
64343
  type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0));
64314
64344
  }
64345
+ function isUnknownLikeUnionType(type) {
64346
+ if (strictNullChecks && type.flags & 1048576 /* Union */) {
64347
+ if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) {
64348
+ var types = type.types;
64349
+ type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* Undefined */ &&
64350
+ types[1].flags & 65536 /* Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0);
64351
+ }
64352
+ return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */);
64353
+ }
64354
+ return false;
64355
+ }
64315
64356
  function isStringIndexSignatureOnlyType(type) {
64316
64357
  return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) ||
64317
64358
  type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) ||
@@ -64391,7 +64432,7 @@ var ts;
64391
64432
  return true;
64392
64433
  if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
64393
64434
  return true;
64394
- if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */)
64435
+ if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source)))
64395
64436
  return true;
64396
64437
  if (relation === assignableRelation || relation === comparableRelation) {
64397
64438
  if (s & 1 /* Any */)
@@ -64401,6 +64442,9 @@ var ts;
64401
64442
  // bit-flag enum types sometimes look like literal enum types with numeric literal values.
64402
64443
  if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */))
64403
64444
  return true;
64445
+ // Anything is assignable to a union containing undefined, null, and {}
64446
+ if (isUnknownLikeUnionType(target))
64447
+ return true;
64404
64448
  }
64405
64449
  return false;
64406
64450
  }
@@ -64443,16 +64487,27 @@ var ts;
64443
64487
  function getNormalizedType(type, writing) {
64444
64488
  while (true) {
64445
64489
  var t = isFreshLiteralType(type) ? type.regularType :
64446
- ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) :
64447
- type.flags & 3145728 /* UnionOrIntersection */ ? getReducedType(type) :
64490
+ ts.getObjectFlags(type) & 4 /* Reference */ ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type :
64491
+ type.flags & 3145728 /* UnionOrIntersection */ ? getNormalizedUnionOrIntersectionType(type, writing) :
64448
64492
  type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute :
64449
64493
  type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) :
64450
64494
  type;
64451
- t = getSingleBaseForNonAugmentingSubtype(t) || t;
64452
64495
  if (t === type)
64453
- break;
64496
+ return t;
64454
64497
  type = t;
64455
64498
  }
64499
+ }
64500
+ function getNormalizedUnionOrIntersectionType(type, writing) {
64501
+ var reduced = getReducedType(type);
64502
+ if (reduced !== type) {
64503
+ return reduced;
64504
+ }
64505
+ if (type.flags & 2097152 /* Intersection */) {
64506
+ var normalizedTypes = ts.sameMap(type.types, function (t) { return getNormalizedType(t, writing); });
64507
+ if (normalizedTypes !== type.types) {
64508
+ return getIntersectionType(normalizedTypes);
64509
+ }
64510
+ }
64456
64511
  return type;
64457
64512
  }
64458
64513
  /**
@@ -64899,6 +64954,7 @@ var ts;
64899
64954
  return 0 /* False */;
64900
64955
  }
64901
64956
  function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
64957
+ var _a, _b;
64902
64958
  var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
64903
64959
  var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
64904
64960
  source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
@@ -64939,6 +64995,9 @@ var ts;
64939
64995
  return;
64940
64996
  }
64941
64997
  reportRelationError(headMessage, source, target);
64998
+ 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 */))) {
64999
+ associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint));
65000
+ }
64942
65001
  }
64943
65002
  function traceUnionsOrIntersectionsTooLarge(source, target) {
64944
65003
  if (!ts.tracing) {
@@ -65725,13 +65784,6 @@ var ts;
65725
65784
  // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
65726
65785
  if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
65727
65786
  var constraint = getConstraintOfType(source) || unknownType;
65728
- if (!getConstraintOfType(source) || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
65729
- // A type variable with no constraint is not related to the non-primitive object type.
65730
- if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
65731
- resetErrorInfo(saveErrorInfo);
65732
- return result;
65733
- }
65734
- }
65735
65787
  // 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
65736
65788
  if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
65737
65789
  resetErrorInfo(saveErrorInfo);
@@ -67205,9 +67257,11 @@ var ts;
67205
67257
  return getSupertypeOrUnion(types);
67206
67258
  }
67207
67259
  var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); });
67208
- return primaryTypes.length ?
67209
- getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* Nullable */) :
67210
- getUnionType(types, 2 /* Subtype */);
67260
+ if (primaryTypes.length) {
67261
+ var supertypeOrUnion = getSupertypeOrUnion(primaryTypes);
67262
+ return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true));
67263
+ }
67264
+ return getUnionType(types, 2 /* Subtype */);
67211
67265
  }
67212
67266
  // Return the leftmost type for which no type to the right is a subtype.
67213
67267
  function getCommonSubtype(types) {
@@ -67406,12 +67460,13 @@ var ts;
67406
67460
  // flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns
67407
67461
  // no flags for all other types (including non-falsy literal types).
67408
67462
  function getFalsyFlags(type) {
67409
- return type.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(type.types) :
67410
- type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 :
67411
- type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 :
67412
- type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 :
67413
- type.flags & 512 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* BooleanLiteral */ : 0 :
67414
- type.flags & 117724 /* PossiblyFalsy */;
67463
+ var t = type.flags & 2097152 /* Intersection */ ? getBaseConstraintOrType(type) : type;
67464
+ return t.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(t.types) :
67465
+ t.flags & 128 /* StringLiteral */ ? t.value === "" ? 128 /* StringLiteral */ : 0 :
67466
+ t.flags & 256 /* NumberLiteral */ ? t.value === 0 ? 256 /* NumberLiteral */ : 0 :
67467
+ t.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(t) ? 2048 /* BigIntLiteral */ : 0 :
67468
+ t.flags & 512 /* BooleanLiteral */ ? (t === falseType || t === regularFalseType) ? 512 /* BooleanLiteral */ : 0 :
67469
+ t.flags & 117724 /* PossiblyFalsy */;
67415
67470
  }
67416
67471
  function removeDefinitelyFalsyTypes(type) {
67417
67472
  return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ?
@@ -67451,20 +67506,22 @@ var ts;
67451
67506
  return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]);
67452
67507
  }
67453
67508
  function getGlobalNonNullableTypeInstantiation(type) {
67454
- // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
67455
- // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
67456
- // that isn't eliminated by a NonNullable<T> instantiation.
67457
- var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
67458
67509
  if (!deferredGlobalNonNullableTypeAlias) {
67459
67510
  deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol;
67460
67511
  }
67461
- // If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
67462
67512
  return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
67463
- getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
67464
- reducedType;
67513
+ getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]) :
67514
+ getIntersectionType([type, emptyObjectType]);
67465
67515
  }
67466
67516
  function getNonNullableType(type) {
67467
- return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
67517
+ if (strictNullChecks) {
67518
+ // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
67519
+ // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
67520
+ // that isn't eliminated by a NonNullable<T> instantiation.
67521
+ var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
67522
+ return maybeTypeOfKind(reducedType, 465829888 /* Instantiable */) ? getGlobalNonNullableTypeInstantiation(reducedType) : reducedType;
67523
+ }
67524
+ return type;
67468
67525
  }
67469
67526
  function addOptionalTypeMarker(type) {
67470
67527
  return strictNullChecks ? getUnionType([type, optionalType]) : type;
@@ -68145,13 +68202,40 @@ var ts;
68145
68202
  return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
68146
68203
  sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
68147
68204
  }
68148
- function isValidBigIntString(s) {
68205
+ /**
68206
+ * Tests whether the provided string can be parsed as a number.
68207
+ * @param s The string to test.
68208
+ * @param roundTripOnly Indicates the resulting number matches the input when converted back to a string.
68209
+ */
68210
+ function isValidNumberString(s, roundTripOnly) {
68211
+ if (s === "")
68212
+ return false;
68213
+ var n = +s;
68214
+ return isFinite(n) && (!roundTripOnly || "" + n === s);
68215
+ }
68216
+ /**
68217
+ * @param text a valid bigint string excluding a trailing `n`, but including a possible prefix `-`. Use `isValidBigIntString(text, roundTripOnly)` before calling this function.
68218
+ */
68219
+ function parseBigIntLiteralType(text) {
68220
+ var negative = text.startsWith("-");
68221
+ var base10Value = ts.parsePseudoBigInt((negative ? text.slice(1) : text) + "n");
68222
+ return getBigIntLiteralType({ negative: negative, base10Value: base10Value });
68223
+ }
68224
+ /**
68225
+ * Tests whether the provided string can be parsed as a bigint.
68226
+ * @param s The string to test.
68227
+ * @param roundTripOnly Indicates the resulting bigint matches the input when converted back to a string.
68228
+ */
68229
+ function isValidBigIntString(s, roundTripOnly) {
68230
+ if (s === "")
68231
+ return false;
68149
68232
  var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false);
68150
68233
  var success = true;
68151
68234
  scanner.setOnError(function () { return success = false; });
68152
68235
  scanner.setText(s + "n");
68153
68236
  var result = scanner.scan();
68154
- if (result === 40 /* MinusToken */) {
68237
+ var negative = result === 40 /* MinusToken */;
68238
+ if (negative) {
68155
68239
  result = scanner.scan();
68156
68240
  }
68157
68241
  var flags = scanner.getTokenFlags();
@@ -68160,7 +68244,8 @@ var ts;
68160
68244
  // * a bigint can be scanned, and that when it is scanned, it is
68161
68245
  // * the full length of the input string (so the scanner is one character beyond the augmented input length)
68162
68246
  // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input)
68163
- return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */);
68247
+ return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
68248
+ && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
68164
68249
  }
68165
68250
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
68166
68251
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
@@ -68168,8 +68253,8 @@ var ts;
68168
68253
  }
68169
68254
  if (source.flags & 128 /* StringLiteral */) {
68170
68255
  var value = source.value;
68171
- return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) ||
68172
- target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) ||
68256
+ return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
68257
+ target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
68173
68258
  target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
68174
68259
  }
68175
68260
  if (source.flags & 134217728 /* TemplateLiteral */) {
@@ -68742,8 +68827,57 @@ var ts;
68742
68827
  // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
68743
68828
  // succeed. That would be a pointless and confusing outcome.
68744
68829
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
68830
+ var _loop_23 = function (i) {
68831
+ var source_1 = matches ? matches[i] : neverType;
68832
+ var target_3 = types[i];
68833
+ // If we are inferring from a string literal type to a type variable whose constraint includes one of the
68834
+ // allowed template literal placeholder types, infer from a literal type corresponding to the constraint.
68835
+ if (source_1.flags & 128 /* StringLiteral */ && target_3.flags & 8650752 /* TypeVariable */) {
68836
+ var inferenceContext = getInferenceInfoForType(target_3);
68837
+ var constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : undefined;
68838
+ if (constraint && !isTypeAny(constraint)) {
68839
+ var constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint];
68840
+ var allTypeFlags_1 = ts.reduceLeft(constraintTypes, function (flags, t) { return flags | t.flags; }, 0);
68841
+ // If the constraint contains `string`, we don't need to look for a more preferred type
68842
+ if (!(allTypeFlags_1 & 4 /* String */)) {
68843
+ var str_1 = source_1.value;
68844
+ // If the type contains `number` or a number literal and the string isn't a valid number, exclude numbers
68845
+ if (allTypeFlags_1 & 296 /* NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) {
68846
+ allTypeFlags_1 &= ~296 /* NumberLike */;
68847
+ }
68848
+ // If the type contains `bigint` or a bigint literal and the string isn't a valid bigint, exclude bigints
68849
+ if (allTypeFlags_1 & 2112 /* BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) {
68850
+ allTypeFlags_1 &= ~2112 /* BigIntLike */;
68851
+ }
68852
+ // for each type in the constraint, find the highest priority matching type
68853
+ var matchingType = ts.reduceLeft(constraintTypes, function (left, right) {
68854
+ return !(right.flags & allTypeFlags_1) ? left :
68855
+ left.flags & 4 /* String */ ? left : right.flags & 4 /* String */ ? source_1 :
68856
+ left.flags & 134217728 /* TemplateLiteral */ ? left : right.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 :
68857
+ left.flags & 268435456 /* StringMapping */ ? left : right.flags & 268435456 /* StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 :
68858
+ left.flags & 128 /* StringLiteral */ ? left : right.flags & 128 /* StringLiteral */ && right.value === str_1 ? right :
68859
+ left.flags & 8 /* Number */ ? left : right.flags & 8 /* Number */ ? getNumberLiteralType(+str_1) :
68860
+ left.flags & 32 /* Enum */ ? left : right.flags & 32 /* Enum */ ? getNumberLiteralType(+str_1) :
68861
+ left.flags & 256 /* NumberLiteral */ ? left : right.flags & 256 /* NumberLiteral */ && right.value === +str_1 ? right :
68862
+ left.flags & 64 /* BigInt */ ? left : right.flags & 64 /* BigInt */ ? parseBigIntLiteralType(str_1) :
68863
+ left.flags & 2048 /* BigIntLiteral */ ? left : right.flags & 2048 /* BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right :
68864
+ left.flags & 16 /* Boolean */ ? left : right.flags & 16 /* Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType :
68865
+ left.flags & 512 /* BooleanLiteral */ ? left : right.flags & 512 /* BooleanLiteral */ && right.intrinsicName === str_1 ? right :
68866
+ left.flags & 32768 /* Undefined */ ? left : right.flags & 32768 /* Undefined */ && right.intrinsicName === str_1 ? right :
68867
+ left.flags & 65536 /* Null */ ? left : right.flags & 65536 /* Null */ && right.intrinsicName === str_1 ? right :
68868
+ left;
68869
+ }, neverType);
68870
+ if (!(matchingType.flags & 131072 /* Never */)) {
68871
+ inferFromTypes(matchingType, target_3);
68872
+ return "continue";
68873
+ }
68874
+ }
68875
+ }
68876
+ }
68877
+ inferFromTypes(source_1, target_3);
68878
+ };
68745
68879
  for (var i = 0; i < types.length; i++) {
68746
- inferFromTypes(matches ? matches[i] : neverType, types[i]);
68880
+ _loop_23(i);
68747
68881
  }
68748
68882
  }
68749
68883
  }
@@ -69261,7 +69395,7 @@ var ts;
69261
69395
  function mapTypesByKeyProperty(types, name) {
69262
69396
  var map = new ts.Map();
69263
69397
  var count = 0;
69264
- var _loop_23 = function (type) {
69398
+ var _loop_24 = function (type) {
69265
69399
  if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
69266
69400
  var discriminant = getTypeOfPropertyOfType(type, name);
69267
69401
  if (discriminant) {
@@ -69287,7 +69421,7 @@ var ts;
69287
69421
  };
69288
69422
  for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
69289
69423
  var type = types_16[_i];
69290
- var state_9 = _loop_23(type);
69424
+ var state_9 = _loop_24(type);
69291
69425
  if (typeof state_9 === "object")
69292
69426
  return state_9.value;
69293
69427
  }
@@ -69495,6 +69629,24 @@ var ts;
69495
69629
  function getTypeWithFacts(type, include) {
69496
69630
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
69497
69631
  }
69632
+ function getIntersectionWithFacts(type, facts) {
69633
+ var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
69634
+ if (strictNullChecks) {
69635
+ switch (facts) {
69636
+ case 524288 /* NEUndefined */:
69637
+ 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; });
69638
+ case 1048576 /* NENull */:
69639
+ 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; });
69640
+ case 2097152 /* NEUndefinedOrNull */:
69641
+ case 4194304 /* Truthy */:
69642
+ return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; });
69643
+ }
69644
+ }
69645
+ return reduced;
69646
+ }
69647
+ function recombineUnknownType(type) {
69648
+ return type === unknownUnionType ? unknownType : type;
69649
+ }
69498
69650
  function getTypeWithDefault(type, defaultExpression) {
69499
69651
  return defaultExpression ?
69500
69652
  getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) :
@@ -70552,7 +70704,7 @@ var ts;
70552
70704
  if (isEvolvingArrayTypeList(types)) {
70553
70705
  return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType)));
70554
70706
  }
70555
- var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction);
70707
+ var result = recombineUnknownType(getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction));
70556
70708
  if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) {
70557
70709
  return declaredType;
70558
70710
  }
@@ -70654,8 +70806,7 @@ var ts;
70654
70806
  }
70655
70807
  function narrowTypeByTruthiness(type, expr, assumeTrue) {
70656
70808
  if (isMatchingReference(reference, expr)) {
70657
- return type.flags & 2 /* Unknown */ && assumeTrue ? nonNullUnknownType :
70658
- getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
70809
+ return getIntersectionWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
70659
70810
  }
70660
70811
  if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
70661
70812
  type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
@@ -70808,9 +70959,6 @@ var ts;
70808
70959
  assumeTrue = !assumeTrue;
70809
70960
  }
70810
70961
  var valueType = getTypeOfExpression(value);
70811
- if (assumeTrue && (type.flags & 2 /* Unknown */) && (operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */) && (valueType.flags & 65536 /* Null */)) {
70812
- return getUnionType([nullType, undefinedType]);
70813
- }
70814
70962
  if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) {
70815
70963
  if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) {
70816
70964
  return valueType;
@@ -70830,7 +70978,7 @@ var ts;
70830
70978
  valueType.flags & 65536 /* Null */ ?
70831
70979
  assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ :
70832
70980
  assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */;
70833
- return type.flags & 2 /* Unknown */ && facts & (1048576 /* NENull */ | 2097152 /* NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts);
70981
+ return getIntersectionWithFacts(type, facts);
70834
70982
  }
70835
70983
  if (assumeTrue) {
70836
70984
  var filterFn = operator === 34 /* EqualsEqualsToken */ ?
@@ -70858,17 +71006,11 @@ var ts;
70858
71006
  if (type.flags & 1 /* Any */ && literal.text === "function") {
70859
71007
  return type;
70860
71008
  }
70861
- if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") {
70862
- // The non-null unknown type is used to track whether a previous narrowing operation has removed the null type
70863
- // from the unknown type. For example, the expression `x && typeof x === 'object'` first narrows x to the non-null
70864
- // unknown type, and then narrows that to the non-primitive type.
70865
- return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]);
70866
- }
70867
71009
  var facts = assumeTrue ?
70868
71010
  typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ :
70869
71011
  typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */;
70870
71012
  var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
70871
- return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts);
71013
+ return getTypeWithFacts(assumeTrue && impliedType ? narrowTypeByImpliedType(type, impliedType) : type, facts);
70872
71014
  }
70873
71015
  function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
70874
71016
  var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
@@ -70917,10 +71059,10 @@ var ts;
70917
71059
  }
70918
71060
  function getImpliedTypeFromTypeofGuard(type, text) {
70919
71061
  switch (text) {
71062
+ case "object":
71063
+ return type.flags & 1 /* Any */ ? type : getUnionType([nullType, nonPrimitiveType]);
70920
71064
  case "function":
70921
71065
  return type.flags & 1 /* Any */ ? type : globalFunctionType;
70922
- case "object":
70923
- return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type;
70924
71066
  default:
70925
71067
  return typeofTypesByName.get(text);
70926
71068
  }
@@ -70931,22 +71073,27 @@ var ts;
70931
71073
  // the guard. For example: narrowing `{} | undefined` by `"boolean"` should produce the type `boolean`, not
70932
71074
  // the filtered type `{}`. For this reason we narrow constituents of the union individually, in addition to
70933
71075
  // filtering by type-facts.
70934
- function narrowUnionMemberByTypeof(candidate) {
70935
- return function (type) {
70936
- if (isTypeSubtypeOf(type, candidate)) {
70937
- return type;
70938
- }
70939
- if (isTypeSubtypeOf(candidate, type)) {
70940
- return candidate;
71076
+ function narrowTypeByImpliedType(type, candidate) {
71077
+ if (type.flags & 3 /* AnyOrUnknown */) {
71078
+ return candidate;
71079
+ }
71080
+ return mapType(type, function (t) {
71081
+ if (isTypeRelatedTo(t, candidate, strictSubtypeRelation)) {
71082
+ return t;
70941
71083
  }
70942
- if (type.flags & 465829888 /* Instantiable */) {
70943
- var constraint = getBaseConstraintOfType(type) || anyType;
70944
- if (isTypeSubtypeOf(candidate, constraint)) {
70945
- return getIntersectionType([type, candidate]);
71084
+ return mapType(candidate, function (c) {
71085
+ if (!areTypesComparable(t, c)) {
71086
+ return neverType;
70946
71087
  }
70947
- }
70948
- return type;
70949
- };
71088
+ if (c.flags & 131068 /* Primitive */ && t.flags & 524288 /* Object */ && !isEmptyAnonymousObjectType(t)) {
71089
+ return isTypeSubtypeOf(c, t) ? c : neverType;
71090
+ }
71091
+ if (c === globalFunctionType && isTypeSubtypeOf(c, t)) {
71092
+ return c;
71093
+ }
71094
+ return getIntersectionType([t, c]);
71095
+ });
71096
+ });
70950
71097
  }
70951
71098
  function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
70952
71099
  var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, /*retainDefault*/ true);
@@ -71005,7 +71152,7 @@ var ts;
71005
71152
  because it is caught in the first clause.
71006
71153
  */
71007
71154
  var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
71008
- return getTypeWithFacts(mapType(type, narrowUnionMemberByTypeof(impliedType)), switchFacts);
71155
+ return getTypeWithFacts(narrowTypeByImpliedType(type, impliedType), switchFacts);
71009
71156
  }
71010
71157
  function isMatchingConstructorReference(expr) {
71011
71158
  return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
@@ -71309,7 +71456,9 @@ var ts;
71309
71456
  !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
71310
71457
  }
71311
71458
  function isGenericTypeWithUnionConstraint(type) {
71312
- return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
71459
+ return type.flags & 2097152 /* Intersection */ ?
71460
+ ts.some(type.types, isGenericTypeWithUnionConstraint) :
71461
+ !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
71313
71462
  }
71314
71463
  function isGenericTypeWithoutNullableConstraint(type) {
71315
71464
  return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
@@ -71337,7 +71486,7 @@ var ts;
71337
71486
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
71338
71487
  someType(type, isGenericTypeWithUnionConstraint) &&
71339
71488
  (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
71340
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
71489
+ return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
71341
71490
  }
71342
71491
  function isExportOrExportExpression(location) {
71343
71492
  return !!ts.findAncestor(location, function (n) {
@@ -75675,7 +75824,7 @@ var ts;
75675
75824
  if (spreadIndex >= 0) {
75676
75825
  // Create synthetic arguments from spreads of tuple types.
75677
75826
  var effectiveArgs_1 = args.slice(0, spreadIndex);
75678
- var _loop_24 = function (i) {
75827
+ var _loop_25 = function (i) {
75679
75828
  var arg = args[i];
75680
75829
  // We can call checkExpressionCached because spread expressions never have a contextual type.
75681
75830
  var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -75692,7 +75841,7 @@ var ts;
75692
75841
  }
75693
75842
  };
75694
75843
  for (var i = spreadIndex; i < args.length; i++) {
75695
- _loop_24(i);
75844
+ _loop_25(i);
75696
75845
  }
75697
75846
  return effectiveArgs_1;
75698
75847
  }
@@ -76012,7 +76161,7 @@ var ts;
76012
76161
  var min_3 = Number.MAX_VALUE;
76013
76162
  var minIndex = 0;
76014
76163
  var i_1 = 0;
76015
- var _loop_25 = function (c) {
76164
+ var _loop_26 = function (c) {
76016
76165
  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)); };
76017
76166
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
76018
76167
  if (diags_2) {
@@ -76030,7 +76179,7 @@ var ts;
76030
76179
  };
76031
76180
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
76032
76181
  var c = candidatesForArgumentError_1[_a];
76033
- _loop_25(c);
76182
+ _loop_26(c);
76034
76183
  }
76035
76184
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
76036
76185
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -76188,7 +76337,7 @@ var ts;
76188
76337
  }
76189
76338
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
76190
76339
  var parameters = [];
76191
- var _loop_26 = function (i) {
76340
+ var _loop_27 = function (i) {
76192
76341
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
76193
76342
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
76194
76343
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -76196,7 +76345,7 @@ var ts;
76196
76345
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
76197
76346
  };
76198
76347
  for (var i = 0; i < maxNonRestParam; i++) {
76199
- _loop_26(i);
76348
+ _loop_27(i);
76200
76349
  }
76201
76350
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
76202
76351
  var flags = 0 /* None */;
@@ -80253,7 +80402,7 @@ var ts;
80253
80402
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
80254
80403
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
80255
80404
  var indexSignatureMap_1 = new ts.Map();
80256
- var _loop_27 = function (declaration) {
80405
+ var _loop_28 = function (declaration) {
80257
80406
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
80258
80407
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
80259
80408
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -80268,7 +80417,7 @@ var ts;
80268
80417
  };
80269
80418
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
80270
80419
  var declaration = _a[_i];
80271
- _loop_27(declaration);
80420
+ _loop_28(declaration);
80272
80421
  }
80273
80422
  indexSignatureMap_1.forEach(function (entry) {
80274
80423
  if (entry.declarations.length > 1) {
@@ -82464,7 +82613,7 @@ var ts;
82464
82613
  }
82465
82614
  // For a commonjs `const x = require`, validate the alias and exit
82466
82615
  var symbol = getSymbolOfNode(node);
82467
- if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
82616
+ if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* BindingElement */ ? node.parent.parent : node)) {
82468
82617
  checkAliasSymbol(node);
82469
82618
  return;
82470
82619
  }
@@ -83729,7 +83878,7 @@ var ts;
83729
83878
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
83730
83879
  var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ ||
83731
83880
  name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
83732
- var _loop_28 = function (info) {
83881
+ var _loop_29 = function (info) {
83733
83882
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
83734
83883
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
83735
83884
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -83742,7 +83891,7 @@ var ts;
83742
83891
  };
83743
83892
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
83744
83893
  var info = indexInfos_9[_i];
83745
- _loop_28(info);
83894
+ _loop_29(info);
83746
83895
  }
83747
83896
  }
83748
83897
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -83750,7 +83899,7 @@ var ts;
83750
83899
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
83751
83900
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
83752
83901
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
83753
- var _loop_29 = function (info) {
83902
+ var _loop_30 = function (info) {
83754
83903
  if (info === checkInfo)
83755
83904
  return "continue";
83756
83905
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -83765,7 +83914,7 @@ var ts;
83765
83914
  };
83766
83915
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
83767
83916
  var info = indexInfos_10[_i];
83768
- _loop_29(info);
83917
+ _loop_30(info);
83769
83918
  }
83770
83919
  }
83771
83920
  function checkTypeNameIsReserved(name, message) {
@@ -84084,7 +84233,7 @@ var ts;
84084
84233
  var baseTypes = baseTypeNode && getBaseTypes(type);
84085
84234
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
84086
84235
  var baseStaticType = getBaseConstructorTypeOfClass(type);
84087
- var _loop_30 = function (member) {
84236
+ var _loop_31 = function (member) {
84088
84237
  if (ts.hasAmbientModifier(member)) {
84089
84238
  return "continue";
84090
84239
  }
@@ -84101,7 +84250,7 @@ var ts;
84101
84250
  };
84102
84251
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84103
84252
  var member = _a[_i];
84104
- _loop_30(member);
84253
+ _loop_31(member);
84105
84254
  }
84106
84255
  }
84107
84256
  /**
@@ -84189,7 +84338,7 @@ var ts;
84189
84338
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
84190
84339
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
84191
84340
  var issuedMemberError = false;
84192
- var _loop_31 = function (member) {
84341
+ var _loop_32 = function (member) {
84193
84342
  if (ts.isStatic(member)) {
84194
84343
  return "continue";
84195
84344
  }
@@ -84208,7 +84357,7 @@ var ts;
84208
84357
  };
84209
84358
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
84210
84359
  var member = _a[_i];
84211
- _loop_31(member);
84360
+ _loop_32(member);
84212
84361
  }
84213
84362
  if (!issuedMemberError) {
84214
84363
  // check again with diagnostics to generate a less-specific error
@@ -122176,7 +122325,7 @@ var ts;
122176
122325
  });
122177
122326
  // Sort by paths closest to importing file Name directory
122178
122327
  var sortedPaths = [];
122179
- var _loop_32 = function (directory) {
122328
+ var _loop_33 = function (directory) {
122180
122329
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
122181
122330
  var pathsInDirectory;
122182
122331
  allFileNames.forEach(function (_a, fileName) {
@@ -122200,7 +122349,7 @@ var ts;
122200
122349
  };
122201
122350
  var out_directory_1;
122202
122351
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
122203
- var state_10 = _loop_32(directory);
122352
+ var state_10 = _loop_33(directory);
122204
122353
  directory = out_directory_1;
122205
122354
  if (state_10 === "break")
122206
122355
  break;
@@ -123647,6 +123796,7 @@ var ts;
123647
123796
  }
123648
123797
  function reloadFileNamesFromConfigFile() {
123649
123798
  writeLog("Reloading new file names and options");
123799
+ reloadLevel = ts.ConfigFileProgramReloadLevel.None;
123650
123800
  rootFileNames = ts.getFileNamesFromConfigSpecs(compilerOptions.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
123651
123801
  if (ts.updateErrorForNoInputFiles(rootFileNames, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile.configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
123652
123802
  hasChangedConfigFileParsingErrors = true;
@@ -136327,7 +136477,7 @@ var ts;
136327
136477
  ts.Debug.assert(parent.name === node);
136328
136478
  return true;
136329
136479
  case 203 /* BindingElement */:
136330
- return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
136480
+ return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent.parent.parent);
136331
136481
  default:
136332
136482
  return false;
136333
136483
  }
@@ -137793,7 +137943,7 @@ var ts;
137793
137943
  // Use the parent symbol if the location is commonjs require syntax on javascript files only.
137794
137944
  if (ts.isInJSFile(referenceLocation)
137795
137945
  && referenceLocation.parent.kind === 203 /* BindingElement */
137796
- && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
137946
+ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) {
137797
137947
  referenceSymbol = referenceLocation.parent.symbol;
137798
137948
  // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
137799
137949
  // this case, just skip it, since the bound identifiers are not an alias of the import.
@@ -143965,6 +144115,10 @@ var ts;
143965
144115
  }
143966
144116
  var typeDisplayString = printTypeInSingleLine(declarationType);
143967
144117
  if (typeDisplayString) {
144118
+ var isVariableNameMatchesType = preferences.includeInlayVariableTypeHintsWhenTypeMatchesName === false && ts.equateStringsCaseInsensitive(decl.name.getText(), typeDisplayString);
144119
+ if (isVariableNameMatchesType) {
144120
+ return;
144121
+ }
143968
144122
  addTypeHints(typeDisplayString, decl.name.end);
143969
144123
  }
143970
144124
  }
@@ -147165,11 +147319,9 @@ var ts;
147165
147319
  if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) {
147166
147320
  var tokenInfo = formattingScanner.readTokenInfo(parent);
147167
147321
  if (tokenInfo.token.kind === 27 /* CommaToken */ && ts.isCallLikeExpression(parent)) {
147168
- var commaTokenLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line;
147169
- if (startLine !== commaTokenLine) {
147170
- formattingScanner.advance();
147171
- tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined;
147172
- }
147322
+ // consume the comma
147323
+ consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent);
147324
+ tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined;
147173
147325
  }
147174
147326
  // consume the list end token only if it is still belong to the parent
147175
147327
  // there might be the case when current token matches end token but does not considered as one
@@ -174875,6 +175027,7 @@ var ts;
174875
175027
  return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
174876
175028
  }
174877
175029
  function getReferencesWorker(projects, defaultProject, initialLocation, logger) {
175030
+ var _a;
174878
175031
  var perProjectResults = getPerProjectReferences(projects, defaultProject, initialLocation,
174879
175032
  /*isForRename*/ false, function (project, position) {
174880
175033
  logger.info("Finding references to " + position.fileName + " position " + position.pos + " in project " + project.getProjectName());
@@ -174894,7 +175047,7 @@ var ts;
174894
175047
  // have started the other project searches from related symbols. Propagate the
174895
175048
  // correct results to all other projects.
174896
175049
  var defaultProjectResults = perProjectResults.get(defaultProject);
174897
- if (defaultProjectResults[0].references[0].isDefinition === undefined) {
175050
+ if (((_a = defaultProjectResults === null || defaultProjectResults === void 0 ? void 0 : defaultProjectResults[0].references[0]) === null || _a === void 0 ? void 0 : _a.isDefinition) === undefined) {
174898
175051
  // Clear all isDefinition properties
174899
175052
  perProjectResults.forEach(function (projectResults) {
174900
175053
  for (var _i = 0, projectResults_2 = projectResults; _i < projectResults_2.length; _i++) {
@@ -174911,8 +175064,8 @@ var ts;
174911
175064
  var knownSymbolSpans_1 = createDocumentSpanSet();
174912
175065
  for (var _i = 0, defaultProjectResults_1 = defaultProjectResults; _i < defaultProjectResults_1.length; _i++) {
174913
175066
  var referencedSymbol = defaultProjectResults_1[_i];
174914
- for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
174915
- var ref = _b[_a];
175067
+ for (var _b = 0, _c = referencedSymbol.references; _b < _c.length; _b++) {
175068
+ var ref = _c[_b];
174916
175069
  if (ref.isDefinition) {
174917
175070
  knownSymbolSpans_1.add(ref);
174918
175071
  // One is enough - updateIsDefinitionOfReferencedSymbols will fill out the set based on symbols
@@ -175072,11 +175225,9 @@ var ts;
175072
175225
  // it easier for the caller to skip post-processing.
175073
175226
  if (searchedProjects.size === 1) {
175074
175227
  var it = resultsMap.values().next();
175075
- ts.Debug.assert(!it.done);
175076
- return it.value;
175228
+ return it.done ? server.emptyArray : it.value; // There may not be any results at all
175077
175229
  }
175078
175230
  return resultsMap;
175079
- // May enqueue to otherPositionQueue
175080
175231
  function searchPosition(project, location) {
175081
175232
  var projectResults = getResultsForPosition(project, location);
175082
175233
  if (!projectResults)