typescript 4.6.1-rc → 4.6.3

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 = "".concat(ts.versionMajorMinor, ".1-rc");
103
+ ts.version = "4.6.3";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -4840,6 +4840,8 @@ var ts;
4840
4840
  TypeFlags[TypeFlags["ESSymbolLike"] = 12288] = "ESSymbolLike";
4841
4841
  TypeFlags[TypeFlags["VoidLike"] = 49152] = "VoidLike";
4842
4842
  /* @internal */
4843
+ TypeFlags[TypeFlags["DefinitelyNonNullable"] = 470302716] = "DefinitelyNonNullable";
4844
+ /* @internal */
4843
4845
  TypeFlags[TypeFlags["DisjointDomains"] = 469892092] = "DisjointDomains";
4844
4846
  TypeFlags[TypeFlags["UnionOrIntersection"] = 3145728] = "UnionOrIntersection";
4845
4847
  TypeFlags[TypeFlags["StructuredType"] = 3670016] = "StructuredType";
@@ -8081,6 +8083,8 @@ var ts;
8081
8083
  Property_0_cannot_have_an_initializer_because_it_is_marked_abstract: diag(1267, ts.DiagnosticCategory.Error, "Property_0_cannot_have_an_initializer_because_it_is_marked_abstract_1267", "Property '{0}' cannot have an initializer because it is marked abstract."),
8082
8084
  An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type: diag(1268, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268", "An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type."),
8083
8085
  Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided: diag(1269, ts.DiagnosticCategory.Error, "Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided_1269", "Cannot use 'export import' on a type or type-only namespace when the '--isolatedModules' flag is provided."),
8086
+ Decorator_function_return_type_0_is_not_assignable_to_type_1: diag(1270, ts.DiagnosticCategory.Error, "Decorator_function_return_type_0_is_not_assignable_to_type_1_1270", "Decorator function return type '{0}' is not assignable to type '{1}'."),
8087
+ Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any: diag(1271, ts.DiagnosticCategory.Error, "Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any_1271", "Decorator function return type is '{0}' but is expected to be 'void' or 'any'."),
8084
8088
  with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
8085
8089
  await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
8086
8090
  Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."),
@@ -31350,18 +31354,8 @@ var ts;
31350
31354
  if (tryParseSemicolon()) {
31351
31355
  return;
31352
31356
  }
31353
- // If an initializer was parsed but there is still an error in finding the next semicolon,
31354
- // we generally know there was an error already reported in the initializer...
31355
- // class Example { a = new Map([), ) }
31356
- // ~
31357
31357
  if (initializer) {
31358
- // ...unless we've found the start of a block after a property declaration, in which
31359
- // case we can know that regardless of the initializer we should complain on the block.
31360
- // class Example { a = 0 {} }
31361
- // ~
31362
- if (token() === 18 /* OpenBraceToken */) {
31363
- parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */));
31364
- }
31358
+ parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */));
31365
31359
  return;
31366
31360
  }
31367
31361
  parseErrorForMissingSemicolonAfter(name);
@@ -46941,8 +46935,7 @@ var ts;
46941
46935
  IntersectionState[IntersectionState["Source"] = 1] = "Source";
46942
46936
  IntersectionState[IntersectionState["Target"] = 2] = "Target";
46943
46937
  IntersectionState[IntersectionState["PropertyCheck"] = 4] = "PropertyCheck";
46944
- IntersectionState[IntersectionState["UnionIntersectionCheck"] = 8] = "UnionIntersectionCheck";
46945
- IntersectionState[IntersectionState["InPropertyCheck"] = 16] = "InPropertyCheck";
46938
+ IntersectionState[IntersectionState["InPropertyCheck"] = 8] = "InPropertyCheck";
46946
46939
  })(IntersectionState || (IntersectionState = {}));
46947
46940
  var RecursionFlags;
46948
46941
  (function (RecursionFlags) {
@@ -63228,11 +63221,11 @@ var ts;
63228
63221
  var overflow = false;
63229
63222
  var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid
63230
63223
  var lastSkippedInfo;
63231
- var incompatibleStack = [];
63224
+ var incompatibleStack;
63232
63225
  var inPropertyCheck = false;
63233
63226
  ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
63234
63227
  var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage);
63235
- if (incompatibleStack.length) {
63228
+ if (incompatibleStack) {
63236
63229
  reportIncompatibleStack();
63237
63230
  }
63238
63231
  if (overflow) {
@@ -63289,19 +63282,19 @@ var ts;
63289
63282
  return {
63290
63283
  errorInfo: errorInfo,
63291
63284
  lastSkippedInfo: lastSkippedInfo,
63292
- incompatibleStack: incompatibleStack.slice(),
63285
+ incompatibleStack: incompatibleStack === null || incompatibleStack === void 0 ? void 0 : incompatibleStack.slice(),
63293
63286
  overrideNextErrorInfo: overrideNextErrorInfo,
63294
- relatedInfo: !relatedInfo ? undefined : relatedInfo.slice()
63287
+ relatedInfo: relatedInfo === null || relatedInfo === void 0 ? void 0 : relatedInfo.slice(),
63295
63288
  };
63296
63289
  }
63297
63290
  function reportIncompatibleError(message, arg0, arg1, arg2, arg3) {
63298
63291
  overrideNextErrorInfo++; // Suppress the next relation error
63299
63292
  lastSkippedInfo = undefined; // Reset skipped info cache
63300
- incompatibleStack.push([message, arg0, arg1, arg2, arg3]);
63293
+ (incompatibleStack || (incompatibleStack = [])).push([message, arg0, arg1, arg2, arg3]);
63301
63294
  }
63302
63295
  function reportIncompatibleStack() {
63303
- var stack = incompatibleStack;
63304
- incompatibleStack = [];
63296
+ var stack = incompatibleStack || [];
63297
+ incompatibleStack = undefined;
63305
63298
  var info = lastSkippedInfo;
63306
63299
  lastSkippedInfo = undefined;
63307
63300
  if (stack.length === 1) {
@@ -63407,7 +63400,7 @@ var ts;
63407
63400
  }
63408
63401
  function reportError(message, arg0, arg1, arg2, arg3) {
63409
63402
  ts.Debug.assert(!!errorNode);
63410
- if (incompatibleStack.length)
63403
+ if (incompatibleStack)
63411
63404
  reportIncompatibleStack();
63412
63405
  if (message.elidedInCompatabilityPyramid)
63413
63406
  return;
@@ -63423,7 +63416,7 @@ var ts;
63423
63416
  }
63424
63417
  }
63425
63418
  function reportRelationError(message, source, target) {
63426
- if (incompatibleStack.length)
63419
+ if (incompatibleStack)
63427
63420
  reportIncompatibleStack();
63428
63421
  var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1];
63429
63422
  var generalizedSource = source;
@@ -63535,7 +63528,9 @@ var ts;
63535
63528
  if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) {
63536
63529
  return -1 /* True */;
63537
63530
  }
63538
- reportErrorResults(originalSource, originalTarget, 0 /* False */, !!(ts.getObjectFlags(originalSource) & 2048 /* JsxAttributes */));
63531
+ if (reportErrors) {
63532
+ reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage);
63533
+ }
63539
63534
  return 0 /* False */;
63540
63535
  }
63541
63536
  // Normalize the source and target types: Turn fresh literal types into regular literal types,
@@ -63547,7 +63542,12 @@ var ts;
63547
63542
  if (source === target)
63548
63543
  return -1 /* True */;
63549
63544
  if (relation === identityRelation) {
63550
- return isIdenticalTo(source, target, recursionFlags);
63545
+ if (source.flags !== target.flags)
63546
+ return 0 /* False */;
63547
+ if (source.flags & 67358815 /* Singleton */)
63548
+ return -1 /* True */;
63549
+ traceUnionsOrIntersectionsTooLarge(source, target);
63550
+ return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
63551
63551
  }
63552
63552
  // We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common,
63553
63553
  // and otherwise, for type parameters in large unions, causes us to need to compare the union to itself,
@@ -63557,163 +63557,130 @@ var ts;
63557
63557
  if (source.flags & 262144 /* TypeParameter */ && getConstraintOfType(source) === target) {
63558
63558
  return -1 /* True */;
63559
63559
  }
63560
- // Try to see if we're relating something like `Foo` -> `Bar | null | undefined`.
63561
- // If so, reporting the `null` and `undefined` in the type is hardly useful.
63562
- // First, see if we're even relating an object type to a union.
63563
- // Then see if the target is stripped down to a single non-union type.
63564
- // Note
63565
- // * We actually want to remove null and undefined naively here (rather than using getNonNullableType),
63566
- // since we don't want to end up with a worse error like "`Foo` is not assignable to `NonNullable<T>`"
63567
- // when dealing with generics.
63568
- // * We also don't deal with primitive source types, since we already halt elaboration below.
63569
- if (target.flags & 1048576 /* Union */ && source.flags & 524288 /* Object */ &&
63570
- target.types.length <= 3 && maybeTypeOfKind(target, 98304 /* Nullable */)) {
63571
- var nullStrippedTarget = extractTypesOfKind(target, ~98304 /* Nullable */);
63572
- if (!(nullStrippedTarget.flags & (1048576 /* Union */ | 131072 /* Never */))) {
63573
- target = getNormalizedType(nullStrippedTarget, /*writing*/ true);
63574
- }
63575
- if (source === nullStrippedTarget)
63576
- return -1 /* True */;
63560
+ // See if we're relating a definitely non-nullable type to a union that includes null and/or undefined
63561
+ // plus a single non-nullable type. If so, remove null and/or undefined from the target type.
63562
+ if (source.flags & 470302716 /* DefinitelyNonNullable */ && target.flags & 1048576 /* Union */) {
63563
+ var types = target.types;
63564
+ var candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] :
63565
+ types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] :
63566
+ undefined;
63567
+ if (candidate && !(candidate.flags & 98304 /* Nullable */)) {
63568
+ target = getNormalizedType(candidate, /*writing*/ true);
63569
+ if (source === target)
63570
+ return -1 /* True */;
63571
+ }
63577
63572
  }
63578
63573
  if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) ||
63579
63574
  isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined))
63580
63575
  return -1 /* True */;
63581
- var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */);
63582
- var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384 /* FreshLiteral */);
63583
- if (isPerformingExcessPropertyChecks) {
63584
- if (hasExcessProperties(source, target, reportErrors)) {
63576
+ if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) {
63577
+ var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384 /* FreshLiteral */);
63578
+ if (isPerformingExcessPropertyChecks) {
63579
+ if (hasExcessProperties(source, target, reportErrors)) {
63580
+ if (reportErrors) {
63581
+ reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target);
63582
+ }
63583
+ return 0 /* False */;
63584
+ }
63585
+ }
63586
+ var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) &&
63587
+ source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType &&
63588
+ target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) &&
63589
+ (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
63590
+ var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */);
63591
+ if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
63585
63592
  if (reportErrors) {
63586
- reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target);
63593
+ var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source);
63594
+ var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
63595
+ var calls = getSignaturesOfType(source, 0 /* Call */);
63596
+ var constructs = getSignaturesOfType(source, 1 /* Construct */);
63597
+ if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) ||
63598
+ constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) {
63599
+ reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
63600
+ }
63601
+ else {
63602
+ reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString);
63603
+ }
63587
63604
  }
63588
63605
  return 0 /* False */;
63589
63606
  }
63590
- }
63591
- var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) &&
63592
- source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType &&
63593
- target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) &&
63594
- (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
63595
- if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
63596
- if (reportErrors) {
63597
- var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source);
63598
- var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
63599
- var calls = getSignaturesOfType(source, 0 /* Call */);
63600
- var constructs = getSignaturesOfType(source, 1 /* Construct */);
63601
- if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) ||
63602
- constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) {
63603
- reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
63604
- }
63605
- else {
63606
- reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString);
63607
- }
63607
+ traceUnionsOrIntersectionsTooLarge(source, target);
63608
+ var skipCaching = source.flags & 1048576 /* Union */ && source.types.length < 4 && !(target.flags & 1048576 /* Union */) ||
63609
+ target.flags & 1048576 /* Union */ && target.types.length < 4 && !(source.flags & 469499904 /* StructuredOrInstantiable */);
63610
+ var result_7 = skipCaching ?
63611
+ unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
63612
+ recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
63613
+ // For certain combinations involving intersections and optional, excess, or mismatched properties we need
63614
+ // an extra property check where the intersection is viewed as a single object. The following are motivating
63615
+ // examples that all should be errors, but aren't without this extra property check:
63616
+ //
63617
+ // let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
63618
+ //
63619
+ // declare let wrong: { a: { y: string } };
63620
+ // let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
63621
+ //
63622
+ // function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
63623
+ // x = y; // Mismatched property in source intersection
63624
+ // }
63625
+ //
63626
+ // We suppress recursive intersection property checks because they can generate lots of work when relating
63627
+ // recursive intersections that are structurally similar but not exactly identical. See #37854.
63628
+ if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
63629
+ isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 524288 /* NonInferrableType */); }))) {
63630
+ inPropertyCheck = true;
63631
+ result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
63632
+ inPropertyCheck = false;
63633
+ }
63634
+ if (result_7) {
63635
+ return result_7;
63608
63636
  }
63609
- return 0 /* False */;
63610
- }
63611
- traceUnionsOrIntersectionsTooLarge(source, target);
63612
- var result = 0 /* False */;
63613
- var saveErrorInfo = captureErrorCalculationState();
63614
- if ((source.flags & 1048576 /* Union */ || target.flags & 1048576 /* Union */) && getConstituentCount(source) * getConstituentCount(target) < 4) {
63615
- // We skip caching when source or target is a union with no more than three constituents.
63616
- result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */);
63617
63637
  }
63618
- else if (source.flags & 3145728 /* UnionOrIntersection */ || target.flags & 3145728 /* UnionOrIntersection */) {
63619
- result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */, recursionFlags);
63638
+ if (reportErrors) {
63639
+ reportErrorResults(originalSource, originalTarget, source, target, headMessage);
63620
63640
  }
63621
- if (!result && !(source.flags & 1048576 /* Union */) && (source.flags & (469499904 /* StructuredOrInstantiable */) || target.flags & 469499904 /* StructuredOrInstantiable */)) {
63622
- if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags)) {
63623
- resetErrorInfo(saveErrorInfo);
63641
+ return 0 /* False */;
63642
+ }
63643
+ function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
63644
+ var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
63645
+ var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
63646
+ source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
63647
+ target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
63648
+ var maybeSuppress = overrideNextErrorInfo > 0;
63649
+ if (maybeSuppress) {
63650
+ overrideNextErrorInfo--;
63651
+ }
63652
+ if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
63653
+ var currentError = errorInfo;
63654
+ tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ true);
63655
+ if (errorInfo !== currentError) {
63656
+ maybeSuppress = !!errorInfo;
63657
+ }
63658
+ }
63659
+ if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) {
63660
+ tryElaborateErrorsForPrimitivesAndObjects(source, target);
63661
+ }
63662
+ else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) {
63663
+ reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
63664
+ }
63665
+ else if (ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && target.flags & 2097152 /* Intersection */) {
63666
+ var targetTypes = target.types;
63667
+ var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
63668
+ var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
63669
+ if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
63670
+ (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
63671
+ // do not report top error
63672
+ return;
63624
63673
  }
63625
63674
  }
63626
- if (!result && source.flags & (2097152 /* Intersection */ | 262144 /* TypeParameter */)) {
63627
- // The combined constraint of an intersection type is the intersection of the constraints of
63628
- // the constituents. When an intersection type contains instantiable types with union type
63629
- // constraints, there are situations where we need to examine the combined constraint. One is
63630
- // when the target is a union type. Another is when the intersection contains types belonging
63631
- // to one of the disjoint domains. For example, given type variables T and U, each with the
63632
- // constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
63633
- // we need to check this constraint against a union on the target side. Also, given a type
63634
- // variable V constrained to 'string | number', 'V & number' has a combined constraint of
63635
- // 'string & number | number & number' which reduces to just 'number'.
63636
- // This also handles type parameters, as a type parameter with a union constraint compared against a union
63637
- // needs to have its constraint hoisted into an intersection with said type parameter, this way
63638
- // the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
63639
- // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
63640
- var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
63641
- if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) {
63642
- if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
63643
- // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
63644
- if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
63645
- resetErrorInfo(saveErrorInfo);
63646
- }
63647
- }
63648
- }
63675
+ else {
63676
+ errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
63649
63677
  }
63650
- // For certain combinations involving intersections and optional, excess, or mismatched properties we need
63651
- // an extra property check where the intersection is viewed as a single object. The following are motivating
63652
- // examples that all should be errors, but aren't without this extra property check:
63653
- //
63654
- // let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
63655
- //
63656
- // declare let wrong: { a: { y: string } };
63657
- // let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
63658
- //
63659
- // function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
63660
- // x = y; // Mismatched property in source intersection
63661
- // }
63662
- //
63663
- // We suppress recursive intersection property checks because they can generate lots of work when relating
63664
- // recursive intersections that are structurally similar but not exactly identical. See #37854.
63665
- if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
63666
- isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 524288 /* NonInferrableType */); }))) {
63667
- inPropertyCheck = true;
63668
- result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
63669
- inPropertyCheck = false;
63670
- }
63671
- reportErrorResults(source, target, result, isComparingJsxAttributes);
63672
- return result;
63673
- function reportErrorResults(source, target, result, isComparingJsxAttributes) {
63674
- if (!result && reportErrors) {
63675
- var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
63676
- var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
63677
- source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
63678
- target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
63679
- var maybeSuppress = overrideNextErrorInfo > 0;
63680
- if (maybeSuppress) {
63681
- overrideNextErrorInfo--;
63682
- }
63683
- if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
63684
- var currentError = errorInfo;
63685
- tryElaborateArrayLikeErrors(source, target, reportErrors);
63686
- if (errorInfo !== currentError) {
63687
- maybeSuppress = !!errorInfo;
63688
- }
63689
- }
63690
- if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) {
63691
- tryElaborateErrorsForPrimitivesAndObjects(source, target);
63692
- }
63693
- else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) {
63694
- reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
63695
- }
63696
- else if (isComparingJsxAttributes && target.flags & 2097152 /* Intersection */) {
63697
- var targetTypes = target.types;
63698
- var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
63699
- var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
63700
- if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
63701
- (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
63702
- // do not report top error
63703
- return result;
63704
- }
63705
- }
63706
- else {
63707
- errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
63708
- }
63709
- if (!headMessage && maybeSuppress) {
63710
- lastSkippedInfo = [source, target];
63711
- // Used by, eg, missing property checking to replace the top-level message with a more informative one
63712
- return result;
63713
- }
63714
- reportRelationError(headMessage, source, target);
63715
- }
63678
+ if (!headMessage && maybeSuppress) {
63679
+ lastSkippedInfo = [source, target];
63680
+ // Used by, eg, missing property checking to replace the top-level message with a more informative one
63681
+ return;
63716
63682
  }
63683
+ reportRelationError(headMessage, source, target);
63717
63684
  }
63718
63685
  function traceUnionsOrIntersectionsTooLarge(source, target) {
63719
63686
  if (!ts.tracing) {
@@ -63740,21 +63707,6 @@ var ts;
63740
63707
  }
63741
63708
  }
63742
63709
  }
63743
- function isIdenticalTo(source, target, recursionFlags) {
63744
- if (source.flags !== target.flags)
63745
- return 0 /* False */;
63746
- if (source.flags & 67358815 /* Singleton */)
63747
- return -1 /* True */;
63748
- traceUnionsOrIntersectionsTooLarge(source, target);
63749
- if (source.flags & 3145728 /* UnionOrIntersection */) {
63750
- var result_7 = eachTypeRelatedToSomeType(source, target);
63751
- if (result_7) {
63752
- result_7 &= eachTypeRelatedToSomeType(target, source);
63753
- }
63754
- return result_7;
63755
- }
63756
- return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
63757
- }
63758
63710
  function getTypeOfPropertyInTypes(types, name) {
63759
63711
  var appendPropType = function (propTypes, type) {
63760
63712
  var _a;
@@ -63853,6 +63805,41 @@ var ts;
63853
63805
  function shouldCheckAsExcessProperty(prop, container) {
63854
63806
  return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration;
63855
63807
  }
63808
+ function unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) {
63809
+ // Note that these checks are specifically ordered to produce correct results. In particular,
63810
+ // we need to deconstruct unions before intersections (because unions are always at the top),
63811
+ // and we need to handle "each" relations before "some" relations for the same kind of type.
63812
+ if (source.flags & 1048576 /* Union */) {
63813
+ return relation === comparableRelation ?
63814
+ someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState) :
63815
+ eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState);
63816
+ }
63817
+ if (target.flags & 1048576 /* Union */) {
63818
+ return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */));
63819
+ }
63820
+ if (target.flags & 2097152 /* Intersection */) {
63821
+ return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */);
63822
+ }
63823
+ // Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
63824
+ // constraints of all non-primitive types in the source into a new intersection. We do this because the
63825
+ // intersection may further constrain the constraints of the non-primitive types. For example, given a type
63826
+ // parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't
63827
+ // appear to be comparable to '2'.
63828
+ if (relation === comparableRelation && target.flags & 131068 /* Primitive */) {
63829
+ var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
63830
+ if (constraints !== source.types) {
63831
+ source = getIntersectionType(constraints);
63832
+ if (!(source.flags & 2097152 /* Intersection */)) {
63833
+ return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
63834
+ }
63835
+ }
63836
+ }
63837
+ // Check to see if any constituents of the intersection are immediately related to the target.
63838
+ // Don't report errors though. Elaborating on whether a source constituent is related to the target is
63839
+ // not actually useful and leads to some confusing error messages. Instead, we rely on the caller
63840
+ // checking whether the full intersection viewed as an object is related to the target.
63841
+ return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */);
63842
+ }
63856
63843
  function eachTypeRelatedToSomeType(source, target) {
63857
63844
  var result = -1 /* True */;
63858
63845
  var sourceTypes = source.types;
@@ -63888,8 +63875,11 @@ var ts;
63888
63875
  }
63889
63876
  }
63890
63877
  if (reportErrors) {
63878
+ // Elaborate only if we can find a best matching type in the target union
63891
63879
  var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
63892
- isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], 2 /* Target */, /*reportErrors*/ true);
63880
+ if (bestMatchingType) {
63881
+ isRelatedTo(source, bestMatchingType, 2 /* Target */, /*reportErrors*/ true);
63882
+ }
63893
63883
  }
63894
63884
  return 0 /* False */;
63895
63885
  }
@@ -64025,7 +64015,7 @@ var ts;
64025
64015
  if (overflow) {
64026
64016
  return 0 /* False */;
64027
64017
  }
64028
- var keyIntersectionState = intersectionState | (inPropertyCheck ? 16 /* InPropertyCheck */ : 0);
64018
+ var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* InPropertyCheck */ : 0);
64029
64019
  var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
64030
64020
  var entry = relation.get(id);
64031
64021
  if (entry !== undefined) {
@@ -64093,6 +64083,7 @@ var ts;
64093
64083
  return originalHandler(onlyUnreliable);
64094
64084
  };
64095
64085
  }
64086
+ var result;
64096
64087
  if (expandingFlags === 3 /* Both */) {
64097
64088
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", {
64098
64089
  sourceId: source.id,
@@ -64102,8 +64093,13 @@ var ts;
64102
64093
  depth: sourceDepth,
64103
64094
  targetDepth: targetDepth
64104
64095
  });
64096
+ result = 3 /* Maybe */;
64097
+ }
64098
+ else {
64099
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
64100
+ result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState);
64101
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
64105
64102
  }
64106
- var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 3 /* Maybe */;
64107
64103
  if (outofbandVarianceMarkerHandler) {
64108
64104
  outofbandVarianceMarkerHandler = originalHandler;
64109
64105
  }
@@ -64135,98 +64131,97 @@ var ts;
64135
64131
  return result;
64136
64132
  }
64137
64133
  function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
64138
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
64139
- var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState);
64140
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
64141
- return result;
64142
- }
64143
- function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) {
64144
64134
  if (intersectionState & 4 /* PropertyCheck */) {
64145
64135
  return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */);
64146
64136
  }
64147
- if (intersectionState & 8 /* UnionIntersectionCheck */) {
64148
- // Note that these checks are specifically ordered to produce correct results. In particular,
64149
- // we need to deconstruct unions before intersections (because unions are always at the top),
64150
- // and we need to handle "each" relations before "some" relations for the same kind of type.
64151
- if (source.flags & 1048576 /* Union */) {
64152
- return relation === comparableRelation ?
64153
- someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState & ~8 /* UnionIntersectionCheck */) :
64154
- eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState & ~8 /* UnionIntersectionCheck */);
64155
- }
64156
- if (target.flags & 1048576 /* Union */) {
64157
- return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */));
64158
- }
64159
- if (target.flags & 2097152 /* Intersection */) {
64160
- return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */);
64161
- }
64162
- // Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
64163
- // constraints of all non-primitive types in the source into a new intersection. We do this because the
64164
- // intersection may further constrain the constraints of the non-primitive types. For example, given a type
64165
- // parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't
64166
- // appear to be comparable to '2'.
64167
- if (relation === comparableRelation && target.flags & 131068 /* Primitive */) {
64168
- var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
64169
- if (constraints !== source.types) {
64170
- source = getIntersectionType(constraints);
64171
- if (!(source.flags & 2097152 /* Intersection */)) {
64172
- return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
64173
- }
64137
+ var result;
64138
+ var originalErrorInfo;
64139
+ var varianceCheckFailed = false;
64140
+ var saveErrorInfo = captureErrorCalculationState();
64141
+ var sourceFlags = source.flags;
64142
+ var targetFlags = target.flags;
64143
+ if (relation === identityRelation) {
64144
+ // We've already checked that source.flags and target.flags are identical
64145
+ if (sourceFlags & 3145728 /* UnionOrIntersection */) {
64146
+ var result_8 = eachTypeRelatedToSomeType(source, target);
64147
+ if (result_8) {
64148
+ result_8 &= eachTypeRelatedToSomeType(target, source);
64174
64149
  }
64150
+ return result_8;
64175
64151
  }
64176
- // Check to see if any constituents of the intersection are immediately related to the target.
64177
- //
64178
- // Don't report errors though. Checking whether a constituent is related to the source is not actually
64179
- // useful and leads to some confusing error messages. Instead it is better to let the below checks
64180
- // take care of this, or to not elaborate at all. For instance,
64181
- //
64182
- // - For an object type (such as 'C = A & B'), users are usually more interested in structural errors.
64183
- //
64184
- // - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection
64185
- // than to report that 'D' is not assignable to 'A' or 'B'.
64186
- //
64187
- // - For a primitive type or type parameter (such as 'number = A & B') there is no point in
64188
- // breaking the intersection apart.
64189
- return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */);
64190
- }
64191
- var flags = source.flags & target.flags;
64192
- if (relation === identityRelation && !(flags & 524288 /* Object */)) {
64193
- if (flags & 4194304 /* Index */) {
64152
+ if (sourceFlags & 4194304 /* Index */) {
64194
64153
  return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false);
64195
64154
  }
64196
- var result_8 = 0 /* False */;
64197
- if (flags & 8388608 /* IndexedAccess */) {
64198
- if (result_8 = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) {
64199
- if (result_8 &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) {
64200
- return result_8;
64155
+ if (sourceFlags & 8388608 /* IndexedAccess */) {
64156
+ if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) {
64157
+ if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) {
64158
+ return result;
64201
64159
  }
64202
64160
  }
64203
64161
  }
64204
- if (flags & 16777216 /* Conditional */) {
64162
+ if (sourceFlags & 16777216 /* Conditional */) {
64205
64163
  if (source.root.isDistributive === target.root.isDistributive) {
64206
- if (result_8 = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) {
64207
- if (result_8 &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) {
64208
- if (result_8 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
64209
- if (result_8 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
64210
- return result_8;
64164
+ if (result = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) {
64165
+ if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) {
64166
+ if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
64167
+ if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
64168
+ return result;
64211
64169
  }
64212
64170
  }
64213
64171
  }
64214
64172
  }
64215
64173
  }
64216
64174
  }
64217
- if (flags & 33554432 /* Substitution */) {
64175
+ if (sourceFlags & 33554432 /* Substitution */) {
64218
64176
  return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false);
64219
64177
  }
64220
- return 0 /* False */;
64178
+ if (!(sourceFlags & 524288 /* Object */)) {
64179
+ return 0 /* False */;
64180
+ }
64181
+ }
64182
+ else if (sourceFlags & 3145728 /* UnionOrIntersection */ || targetFlags & 3145728 /* UnionOrIntersection */) {
64183
+ if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) {
64184
+ return result;
64185
+ }
64186
+ if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) {
64187
+ // The combined constraint of an intersection type is the intersection of the constraints of
64188
+ // the constituents. When an intersection type contains instantiable types with union type
64189
+ // constraints, there are situations where we need to examine the combined constraint. One is
64190
+ // when the target is a union type. Another is when the intersection contains types belonging
64191
+ // to one of the disjoint domains. For example, given type variables T and U, each with the
64192
+ // constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
64193
+ // we need to check this constraint against a union on the target side. Also, given a type
64194
+ // variable V constrained to 'string | number', 'V & number' has a combined constraint of
64195
+ // 'string & number | number & number' which reduces to just 'number'.
64196
+ // This also handles type parameters, as a type parameter with a union constraint compared against a union
64197
+ // needs to have its constraint hoisted into an intersection with said type parameter, this way
64198
+ // the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
64199
+ // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
64200
+ var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
64201
+ if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
64202
+ // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
64203
+ if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
64204
+ resetErrorInfo(saveErrorInfo);
64205
+ return result;
64206
+ }
64207
+ }
64208
+ }
64209
+ // The ordered decomposition above doesn't handle all cases. Specifically, we also need to handle:
64210
+ // Source is instantiable (e.g. source has union or intersection constraint).
64211
+ // Source is an object, target is a union (e.g. { a, b: boolean } <=> { a, b: true } | { a, b: false }).
64212
+ // Source is an intersection, target is an object (e.g. { a } & { b } <=> { a, b }).
64213
+ // Source is an intersection, target is a union (e.g. { a } & { b: boolean } <=> { a, b: true } | { a, b: false }).
64214
+ // Source is an intersection, target instantiable (e.g. string & { tag } <=> T["a"] constrained to string & { tag }).
64215
+ if (!(sourceFlags & 465829888 /* Instantiable */ ||
64216
+ sourceFlags & 524288 /* Object */ && targetFlags & 1048576 /* Union */ ||
64217
+ sourceFlags & 2097152 /* Intersection */ && targetFlags & (524288 /* Object */ | 1048576 /* Union */ | 465829888 /* Instantiable */))) {
64218
+ return 0 /* False */;
64219
+ }
64221
64220
  }
64222
- var result;
64223
- var originalErrorInfo;
64224
- var varianceCheckFailed = false;
64225
- var saveErrorInfo = captureErrorCalculationState();
64226
64221
  // We limit alias variance probing to only object and conditional types since their alias behavior
64227
64222
  // is more predictable than other, interned types, which may or may not have an alias depending on
64228
64223
  // the order in which things were checked.
64229
- if (source.flags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol &&
64224
+ if (sourceFlags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol &&
64230
64225
  source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
64231
64226
  !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) {
64232
64227
  var variances = getAliasVariances(source.aliasSymbol);
@@ -64244,7 +64239,7 @@ var ts;
64244
64239
  isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) {
64245
64240
  return result;
64246
64241
  }
64247
- if (target.flags & 262144 /* TypeParameter */) {
64242
+ if (targetFlags & 262144 /* TypeParameter */) {
64248
64243
  // A source type { [P in Q]: X } is related to a target type T if keyof T is related to Q and X is related to T[Q].
64249
64244
  if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) {
64250
64245
  if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) {
@@ -64256,10 +64251,10 @@ var ts;
64256
64251
  }
64257
64252
  }
64258
64253
  }
64259
- else if (target.flags & 4194304 /* Index */) {
64254
+ else if (targetFlags & 4194304 /* Index */) {
64260
64255
  var targetType_1 = target.type;
64261
64256
  // A keyof S is related to a keyof T if T is related to S.
64262
- if (source.flags & 4194304 /* Index */) {
64257
+ if (sourceFlags & 4194304 /* Index */) {
64263
64258
  if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) {
64264
64259
  return result;
64265
64260
  }
@@ -64310,8 +64305,8 @@ var ts;
64310
64305
  }
64311
64306
  }
64312
64307
  }
64313
- else if (target.flags & 8388608 /* IndexedAccess */) {
64314
- if (source.flags & 8388608 /* IndexedAccess */) {
64308
+ else if (targetFlags & 8388608 /* IndexedAccess */) {
64309
+ if (sourceFlags & 8388608 /* IndexedAccess */) {
64315
64310
  // Relate components directly before falling back to constraint relationships
64316
64311
  // A type S[K] is related to a type T[J] if S is related to T and K is related to J.
64317
64312
  if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) {
@@ -64417,7 +64412,7 @@ var ts;
64417
64412
  }
64418
64413
  }
64419
64414
  }
64420
- else if (target.flags & 16777216 /* Conditional */) {
64415
+ else if (targetFlags & 16777216 /* Conditional */) {
64421
64416
  // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
64422
64417
  // conditional type and bail out with a Ternary.Maybe result.
64423
64418
  if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
@@ -64442,8 +64437,8 @@ var ts;
64442
64437
  }
64443
64438
  }
64444
64439
  }
64445
- else if (target.flags & 134217728 /* TemplateLiteral */) {
64446
- if (source.flags & 134217728 /* TemplateLiteral */) {
64440
+ else if (targetFlags & 134217728 /* TemplateLiteral */) {
64441
+ if (sourceFlags & 134217728 /* TemplateLiteral */) {
64447
64442
  if (relation === comparableRelation) {
64448
64443
  return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */;
64449
64444
  }
@@ -64455,11 +64450,11 @@ var ts;
64455
64450
  return -1 /* True */;
64456
64451
  }
64457
64452
  }
64458
- if (source.flags & 8650752 /* TypeVariable */) {
64459
- // IndexedAccess comparisons are handled above in the `target.flags & TypeFlage.IndexedAccess` branch
64460
- if (!(source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */)) {
64453
+ if (sourceFlags & 8650752 /* TypeVariable */) {
64454
+ // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
64455
+ if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
64461
64456
  var constraint = getConstraintOfType(source);
64462
- if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
64457
+ if (!constraint || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
64463
64458
  // A type variable with no constraint is not related to the non-primitive object type.
64464
64459
  if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
64465
64460
  resetErrorInfo(saveErrorInfo);
@@ -64472,7 +64467,7 @@ var ts;
64472
64467
  return result;
64473
64468
  }
64474
64469
  // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
64475
- else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(target.flags & source.flags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
64470
+ else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
64476
64471
  resetErrorInfo(saveErrorInfo);
64477
64472
  return result;
64478
64473
  }
@@ -64489,14 +64484,14 @@ var ts;
64489
64484
  }
64490
64485
  }
64491
64486
  }
64492
- else if (source.flags & 4194304 /* Index */) {
64487
+ else if (sourceFlags & 4194304 /* Index */) {
64493
64488
  if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
64494
64489
  resetErrorInfo(saveErrorInfo);
64495
64490
  return result;
64496
64491
  }
64497
64492
  }
64498
- else if (source.flags & 134217728 /* TemplateLiteral */ && !(target.flags & 524288 /* Object */)) {
64499
- if (!(target.flags & 134217728 /* TemplateLiteral */)) {
64493
+ else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
64494
+ if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
64500
64495
  var constraint = getBaseConstraintOfType(source);
64501
64496
  if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
64502
64497
  resetErrorInfo(saveErrorInfo);
@@ -64504,8 +64499,8 @@ var ts;
64504
64499
  }
64505
64500
  }
64506
64501
  }
64507
- else if (source.flags & 268435456 /* StringMapping */) {
64508
- if (target.flags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
64502
+ else if (sourceFlags & 268435456 /* StringMapping */) {
64503
+ if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
64509
64504
  if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
64510
64505
  resetErrorInfo(saveErrorInfo);
64511
64506
  return result;
@@ -64519,14 +64514,14 @@ var ts;
64519
64514
  }
64520
64515
  }
64521
64516
  }
64522
- else if (source.flags & 16777216 /* Conditional */) {
64517
+ else if (sourceFlags & 16777216 /* Conditional */) {
64523
64518
  // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
64524
64519
  // conditional type and bail out with a Ternary.Maybe result.
64525
64520
  if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
64526
64521
  resetErrorInfo(saveErrorInfo);
64527
64522
  return 3 /* Maybe */;
64528
64523
  }
64529
- if (target.flags & 16777216 /* Conditional */) {
64524
+ if (targetFlags & 16777216 /* Conditional */) {
64530
64525
  // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
64531
64526
  // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
64532
64527
  // and Y1 is related to Y2.
@@ -64586,9 +64581,10 @@ var ts;
64586
64581
  }
64587
64582
  return 0 /* False */;
64588
64583
  }
64589
- var sourceIsPrimitive = !!(source.flags & 131068 /* Primitive */);
64584
+ var sourceIsPrimitive = !!(sourceFlags & 131068 /* Primitive */);
64590
64585
  if (relation !== identityRelation) {
64591
64586
  source = getApparentType(source);
64587
+ sourceFlags = source.flags;
64592
64588
  }
64593
64589
  else if (isGenericMappedType(source)) {
64594
64590
  return 0 /* False */;
@@ -64630,7 +64626,7 @@ var ts;
64630
64626
  // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates
64631
64627
  // to X. Failing both of those we want to check if the aggregation of A and B's members structurally
64632
64628
  // relates to X. Thus, we include intersection types on the source side here.
64633
- if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 524288 /* Object */) {
64629
+ if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 524288 /* Object */) {
64634
64630
  // Report structural errors only if we haven't reported any errors yet
64635
64631
  var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive;
64636
64632
  result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, intersectionState);
@@ -64654,7 +64650,7 @@ var ts;
64654
64650
  // there exists a constituent of T for every combination of the discriminants of S
64655
64651
  // with respect to T. We do not report errors here, as we will use the existing
64656
64652
  // error result from checking each constituent of the union.
64657
- if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 1048576 /* Union */) {
64653
+ if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 1048576 /* Union */) {
64658
64654
  var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */);
64659
64655
  if (objectOnlyTarget.flags & 1048576 /* Union */) {
64660
64656
  var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
@@ -65169,7 +65165,6 @@ var ts;
65169
65165
  }
65170
65166
  }
65171
65167
  var result = -1 /* True */;
65172
- var saveErrorInfo = captureErrorCalculationState();
65173
65168
  var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
65174
65169
  var sourceObjectFlags = ts.getObjectFlags(source);
65175
65170
  var targetObjectFlags = ts.getObjectFlags(target);
@@ -65210,6 +65205,7 @@ var ts;
65210
65205
  else {
65211
65206
  outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) {
65212
65207
  var t = targetSignatures_1[_i];
65208
+ var saveErrorInfo = captureErrorCalculationState();
65213
65209
  // Only elaborate errors from the first failure
65214
65210
  var shouldElaborateErrors = reportErrors;
65215
65211
  for (var _c = 0, sourceSignatures_1 = sourceSignatures; _c < sourceSignatures_1.length; _c++) {
@@ -68380,9 +68376,6 @@ var ts;
68380
68376
  getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) :
68381
68377
  mapType(type, mapper);
68382
68378
  }
68383
- function getConstituentCount(type) {
68384
- return type.flags & 1048576 /* Union */ ? type.types.length : 1;
68385
- }
68386
68379
  function extractTypesOfKind(type, kind) {
68387
68380
  return filterType(type, function (t) { return (t.flags & kind) !== 0; });
68388
68381
  }
@@ -69956,7 +69949,7 @@ var ts;
69956
69949
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
69957
69950
  someType(type, isGenericTypeWithUnionConstraint) &&
69958
69951
  (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
69959
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
69952
+ return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
69960
69953
  }
69961
69954
  function isExportOrExportExpression(location) {
69962
69955
  return !!ts.findAncestor(location, function (n) {
@@ -70028,6 +70021,9 @@ var ts;
70028
70021
  if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
70029
70022
  var pattern = declaration.parent;
70030
70023
  var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode);
70024
+ if (narrowedType.flags & 131072 /* Never */) {
70025
+ return neverType;
70026
+ }
70031
70027
  return getBindingElementTypeFromParentType(declaration, narrowedType);
70032
70028
  }
70033
70029
  }
@@ -76048,21 +76044,22 @@ var ts;
76048
76044
  if (links.type === unknownType) {
76049
76045
  links.type = getTypeFromBindingPattern(declaration.name);
76050
76046
  }
76051
- assignBindingElementTypes(declaration.name);
76047
+ assignBindingElementTypes(declaration.name, links.type);
76052
76048
  }
76053
76049
  }
76054
76050
  }
76055
76051
  // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push
76056
76052
  // the destructured type into the contained binding elements.
76057
- function assignBindingElementTypes(pattern) {
76053
+ function assignBindingElementTypes(pattern, parentType) {
76058
76054
  for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
76059
76055
  var element = _a[_i];
76060
76056
  if (!ts.isOmittedExpression(element)) {
76057
+ var type = getBindingElementTypeFromParentType(element, parentType);
76061
76058
  if (element.name.kind === 79 /* Identifier */) {
76062
- getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element);
76059
+ getSymbolLinks(getSymbolOfNode(element)).type = type;
76063
76060
  }
76064
76061
  else {
76065
- assignBindingElementTypes(element.name);
76062
+ assignBindingElementTypes(element.name, type);
76066
76063
  }
76067
76064
  }
76068
76065
  }
@@ -79803,28 +79800,24 @@ var ts;
79803
79800
  if (returnType.flags & 1 /* Any */) {
79804
79801
  return;
79805
79802
  }
79803
+ var headMessage;
79806
79804
  var expectedReturnType;
79807
- var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
79808
- var errorInfo;
79809
79805
  switch (node.parent.kind) {
79810
79806
  case 256 /* ClassDeclaration */:
79807
+ headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
79811
79808
  var classSymbol = getSymbolOfNode(node.parent);
79812
79809
  var classConstructorType = getTypeOfSymbol(classSymbol);
79813
79810
  expectedReturnType = getUnionType([classConstructorType, voidType]);
79814
79811
  break;
79815
- case 163 /* Parameter */:
79816
- expectedReturnType = voidType;
79817
- errorInfo = ts.chainDiagnosticMessages(
79818
- /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any);
79819
- break;
79820
79812
  case 166 /* PropertyDeclaration */:
79813
+ case 163 /* Parameter */:
79814
+ headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any;
79821
79815
  expectedReturnType = voidType;
79822
- errorInfo = ts.chainDiagnosticMessages(
79823
- /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any);
79824
79816
  break;
79825
79817
  case 168 /* MethodDeclaration */:
79826
79818
  case 171 /* GetAccessor */:
79827
79819
  case 172 /* SetAccessor */:
79820
+ headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
79828
79821
  var methodType = getTypeOfNode(node.parent);
79829
79822
  var descriptorType = createTypedPropertyDescriptorType(methodType);
79830
79823
  expectedReturnType = getUnionType([descriptorType, voidType]);
@@ -79832,7 +79825,7 @@ var ts;
79832
79825
  default:
79833
79826
  return ts.Debug.fail();
79834
79827
  }
79835
- checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, function () { return errorInfo; });
79828
+ checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage);
79836
79829
  }
79837
79830
  /**
79838
79831
  * If a TypeNode can be resolved to a value symbol imported from an external module, it is
@@ -82105,9 +82098,9 @@ var ts;
82105
82098
  var containsArguments = containsArgumentsReference(node);
82106
82099
  if (containsArguments) {
82107
82100
  var lastJSDocParam = ts.lastOrUndefined(jsdocParameters);
82108
- if (lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
82101
+ if (isJs && lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
82109
82102
  lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
82110
- errorOrSuggestion(isJs, lastJSDocParam.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(lastJSDocParam.name));
82103
+ error(lastJSDocParam.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(lastJSDocParam.name));
82111
82104
  }
82112
82105
  }
82113
82106
  else {
@@ -82117,7 +82110,9 @@ var ts;
82117
82110
  return;
82118
82111
  }
82119
82112
  if (ts.isQualifiedName(name)) {
82120
- errorOrSuggestion(isJs, name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
82113
+ if (isJs) {
82114
+ error(name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
82115
+ }
82121
82116
  }
82122
82117
  else {
82123
82118
  errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
@@ -87296,28 +87291,27 @@ var ts;
87296
87291
  }
87297
87292
  function findMostOverlappyType(source, unionTarget) {
87298
87293
  var bestMatch;
87299
- var matchingCount = 0;
87300
- for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
87301
- var target = _a[_i];
87302
- var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
87303
- if (overlap.flags & 4194304 /* Index */) {
87304
- // perfect overlap of keys
87305
- bestMatch = target;
87306
- matchingCount = Infinity;
87307
- }
87308
- else if (overlap.flags & 1048576 /* Union */) {
87309
- // We only want to account for literal types otherwise.
87310
- // If we have a union of index types, it seems likely that we
87311
- // needed to elaborate between two generic mapped types anyway.
87312
- var len = ts.length(ts.filter(overlap.types, isUnitType));
87313
- if (len >= matchingCount) {
87314
- bestMatch = target;
87315
- matchingCount = len;
87316
- }
87317
- }
87318
- else if (isUnitType(overlap) && 1 >= matchingCount) {
87319
- bestMatch = target;
87320
- matchingCount = 1;
87294
+ if (!(source.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) {
87295
+ var matchingCount = 0;
87296
+ for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
87297
+ var target = _a[_i];
87298
+ if (!(target.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) {
87299
+ var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
87300
+ if (overlap.flags & 4194304 /* Index */) {
87301
+ // perfect overlap of keys
87302
+ return target;
87303
+ }
87304
+ else if (isUnitType(overlap) || overlap.flags & 1048576 /* Union */) {
87305
+ // We only want to account for literal types otherwise.
87306
+ // If we have a union of index types, it seems likely that we
87307
+ // needed to elaborate between two generic mapped types anyway.
87308
+ var len = overlap.flags & 1048576 /* Union */ ? ts.countWhere(overlap.types, isUnitType) : 1;
87309
+ if (len >= matchingCount) {
87310
+ bestMatch = target;
87311
+ matchingCount = len;
87312
+ }
87313
+ }
87314
+ }
87321
87315
  }
87322
87316
  }
87323
87317
  return bestMatch;
@@ -140010,6 +140004,41 @@ var ts;
140010
140004
  if (ts.scanner.getToken() === 1 /* EndOfFileToken */) {
140011
140005
  break;
140012
140006
  }
140007
+ if (ts.scanner.getToken() === 15 /* TemplateHead */) {
140008
+ var stack = [ts.scanner.getToken()];
140009
+ var token = ts.scanner.scan();
140010
+ loop: while (ts.length(stack)) {
140011
+ switch (token) {
140012
+ case 1 /* EndOfFileToken */:
140013
+ break loop;
140014
+ case 100 /* ImportKeyword */:
140015
+ tryConsumeImport();
140016
+ break;
140017
+ case 15 /* TemplateHead */:
140018
+ stack.push(token);
140019
+ break;
140020
+ case 18 /* OpenBraceToken */:
140021
+ if (ts.length(stack)) {
140022
+ stack.push(token);
140023
+ }
140024
+ break;
140025
+ case 19 /* CloseBraceToken */:
140026
+ if (ts.length(stack)) {
140027
+ if (ts.lastOrUndefined(stack) === 15 /* TemplateHead */) {
140028
+ if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* TemplateTail */) {
140029
+ stack.pop();
140030
+ }
140031
+ }
140032
+ else {
140033
+ stack.pop();
140034
+ }
140035
+ }
140036
+ break;
140037
+ }
140038
+ token = ts.scanner.scan();
140039
+ }
140040
+ nextToken();
140041
+ }
140013
140042
  // check if at least one of alternative have moved scanner forward
140014
140043
  if (tryConsumeDeclare() ||
140015
140044
  tryConsumeImport() ||
@@ -156817,7 +156846,7 @@ var ts;
156817
156846
  // cannot find either start or end node
156818
156847
  return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
156819
156848
  }
156820
- if (ts.isJSDoc(start)) {
156849
+ if (start.flags & 4194304 /* JSDoc */) {
156821
156850
  return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] };
156822
156851
  }
156823
156852
  if (start.parent !== end.parent) {