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.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = "".concat(ts.versionMajorMinor, ".1-rc");
297
+ ts.version = "4.6.3";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -5034,6 +5034,8 @@ var ts;
5034
5034
  TypeFlags[TypeFlags["ESSymbolLike"] = 12288] = "ESSymbolLike";
5035
5035
  TypeFlags[TypeFlags["VoidLike"] = 49152] = "VoidLike";
5036
5036
  /* @internal */
5037
+ TypeFlags[TypeFlags["DefinitelyNonNullable"] = 470302716] = "DefinitelyNonNullable";
5038
+ /* @internal */
5037
5039
  TypeFlags[TypeFlags["DisjointDomains"] = 469892092] = "DisjointDomains";
5038
5040
  TypeFlags[TypeFlags["UnionOrIntersection"] = 3145728] = "UnionOrIntersection";
5039
5041
  TypeFlags[TypeFlags["StructuredType"] = 3670016] = "StructuredType";
@@ -8275,6 +8277,8 @@ var ts;
8275
8277
  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."),
8276
8278
  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."),
8277
8279
  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."),
8280
+ 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}'."),
8281
+ 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'."),
8278
8282
  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."),
8279
8283
  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."),
8280
8284
  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."),
@@ -31544,18 +31548,8 @@ var ts;
31544
31548
  if (tryParseSemicolon()) {
31545
31549
  return;
31546
31550
  }
31547
- // If an initializer was parsed but there is still an error in finding the next semicolon,
31548
- // we generally know there was an error already reported in the initializer...
31549
- // class Example { a = new Map([), ) }
31550
- // ~
31551
31551
  if (initializer) {
31552
- // ...unless we've found the start of a block after a property declaration, in which
31553
- // case we can know that regardless of the initializer we should complain on the block.
31554
- // class Example { a = 0 {} }
31555
- // ~
31556
- if (token() === 18 /* OpenBraceToken */) {
31557
- parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */));
31558
- }
31552
+ parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */));
31559
31553
  return;
31560
31554
  }
31561
31555
  parseErrorForMissingSemicolonAfter(name);
@@ -47135,8 +47129,7 @@ var ts;
47135
47129
  IntersectionState[IntersectionState["Source"] = 1] = "Source";
47136
47130
  IntersectionState[IntersectionState["Target"] = 2] = "Target";
47137
47131
  IntersectionState[IntersectionState["PropertyCheck"] = 4] = "PropertyCheck";
47138
- IntersectionState[IntersectionState["UnionIntersectionCheck"] = 8] = "UnionIntersectionCheck";
47139
- IntersectionState[IntersectionState["InPropertyCheck"] = 16] = "InPropertyCheck";
47132
+ IntersectionState[IntersectionState["InPropertyCheck"] = 8] = "InPropertyCheck";
47140
47133
  })(IntersectionState || (IntersectionState = {}));
47141
47134
  var RecursionFlags;
47142
47135
  (function (RecursionFlags) {
@@ -63422,11 +63415,11 @@ var ts;
63422
63415
  var overflow = false;
63423
63416
  var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid
63424
63417
  var lastSkippedInfo;
63425
- var incompatibleStack = [];
63418
+ var incompatibleStack;
63426
63419
  var inPropertyCheck = false;
63427
63420
  ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
63428
63421
  var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage);
63429
- if (incompatibleStack.length) {
63422
+ if (incompatibleStack) {
63430
63423
  reportIncompatibleStack();
63431
63424
  }
63432
63425
  if (overflow) {
@@ -63483,19 +63476,19 @@ var ts;
63483
63476
  return {
63484
63477
  errorInfo: errorInfo,
63485
63478
  lastSkippedInfo: lastSkippedInfo,
63486
- incompatibleStack: incompatibleStack.slice(),
63479
+ incompatibleStack: incompatibleStack === null || incompatibleStack === void 0 ? void 0 : incompatibleStack.slice(),
63487
63480
  overrideNextErrorInfo: overrideNextErrorInfo,
63488
- relatedInfo: !relatedInfo ? undefined : relatedInfo.slice()
63481
+ relatedInfo: relatedInfo === null || relatedInfo === void 0 ? void 0 : relatedInfo.slice(),
63489
63482
  };
63490
63483
  }
63491
63484
  function reportIncompatibleError(message, arg0, arg1, arg2, arg3) {
63492
63485
  overrideNextErrorInfo++; // Suppress the next relation error
63493
63486
  lastSkippedInfo = undefined; // Reset skipped info cache
63494
- incompatibleStack.push([message, arg0, arg1, arg2, arg3]);
63487
+ (incompatibleStack || (incompatibleStack = [])).push([message, arg0, arg1, arg2, arg3]);
63495
63488
  }
63496
63489
  function reportIncompatibleStack() {
63497
- var stack = incompatibleStack;
63498
- incompatibleStack = [];
63490
+ var stack = incompatibleStack || [];
63491
+ incompatibleStack = undefined;
63499
63492
  var info = lastSkippedInfo;
63500
63493
  lastSkippedInfo = undefined;
63501
63494
  if (stack.length === 1) {
@@ -63601,7 +63594,7 @@ var ts;
63601
63594
  }
63602
63595
  function reportError(message, arg0, arg1, arg2, arg3) {
63603
63596
  ts.Debug.assert(!!errorNode);
63604
- if (incompatibleStack.length)
63597
+ if (incompatibleStack)
63605
63598
  reportIncompatibleStack();
63606
63599
  if (message.elidedInCompatabilityPyramid)
63607
63600
  return;
@@ -63617,7 +63610,7 @@ var ts;
63617
63610
  }
63618
63611
  }
63619
63612
  function reportRelationError(message, source, target) {
63620
- if (incompatibleStack.length)
63613
+ if (incompatibleStack)
63621
63614
  reportIncompatibleStack();
63622
63615
  var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1];
63623
63616
  var generalizedSource = source;
@@ -63729,7 +63722,9 @@ var ts;
63729
63722
  if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) {
63730
63723
  return -1 /* True */;
63731
63724
  }
63732
- reportErrorResults(originalSource, originalTarget, 0 /* False */, !!(ts.getObjectFlags(originalSource) & 2048 /* JsxAttributes */));
63725
+ if (reportErrors) {
63726
+ reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage);
63727
+ }
63733
63728
  return 0 /* False */;
63734
63729
  }
63735
63730
  // Normalize the source and target types: Turn fresh literal types into regular literal types,
@@ -63741,7 +63736,12 @@ var ts;
63741
63736
  if (source === target)
63742
63737
  return -1 /* True */;
63743
63738
  if (relation === identityRelation) {
63744
- return isIdenticalTo(source, target, recursionFlags);
63739
+ if (source.flags !== target.flags)
63740
+ return 0 /* False */;
63741
+ if (source.flags & 67358815 /* Singleton */)
63742
+ return -1 /* True */;
63743
+ traceUnionsOrIntersectionsTooLarge(source, target);
63744
+ return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
63745
63745
  }
63746
63746
  // We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common,
63747
63747
  // and otherwise, for type parameters in large unions, causes us to need to compare the union to itself,
@@ -63751,163 +63751,130 @@ var ts;
63751
63751
  if (source.flags & 262144 /* TypeParameter */ && getConstraintOfType(source) === target) {
63752
63752
  return -1 /* True */;
63753
63753
  }
63754
- // Try to see if we're relating something like `Foo` -> `Bar | null | undefined`.
63755
- // If so, reporting the `null` and `undefined` in the type is hardly useful.
63756
- // First, see if we're even relating an object type to a union.
63757
- // Then see if the target is stripped down to a single non-union type.
63758
- // Note
63759
- // * We actually want to remove null and undefined naively here (rather than using getNonNullableType),
63760
- // since we don't want to end up with a worse error like "`Foo` is not assignable to `NonNullable<T>`"
63761
- // when dealing with generics.
63762
- // * We also don't deal with primitive source types, since we already halt elaboration below.
63763
- if (target.flags & 1048576 /* Union */ && source.flags & 524288 /* Object */ &&
63764
- target.types.length <= 3 && maybeTypeOfKind(target, 98304 /* Nullable */)) {
63765
- var nullStrippedTarget = extractTypesOfKind(target, ~98304 /* Nullable */);
63766
- if (!(nullStrippedTarget.flags & (1048576 /* Union */ | 131072 /* Never */))) {
63767
- target = getNormalizedType(nullStrippedTarget, /*writing*/ true);
63768
- }
63769
- if (source === nullStrippedTarget)
63770
- return -1 /* True */;
63754
+ // See if we're relating a definitely non-nullable type to a union that includes null and/or undefined
63755
+ // plus a single non-nullable type. If so, remove null and/or undefined from the target type.
63756
+ if (source.flags & 470302716 /* DefinitelyNonNullable */ && target.flags & 1048576 /* Union */) {
63757
+ var types = target.types;
63758
+ var candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] :
63759
+ types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] :
63760
+ undefined;
63761
+ if (candidate && !(candidate.flags & 98304 /* Nullable */)) {
63762
+ target = getNormalizedType(candidate, /*writing*/ true);
63763
+ if (source === target)
63764
+ return -1 /* True */;
63765
+ }
63771
63766
  }
63772
63767
  if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) ||
63773
63768
  isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined))
63774
63769
  return -1 /* True */;
63775
- var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */);
63776
- var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384 /* FreshLiteral */);
63777
- if (isPerformingExcessPropertyChecks) {
63778
- if (hasExcessProperties(source, target, reportErrors)) {
63770
+ if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) {
63771
+ var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384 /* FreshLiteral */);
63772
+ if (isPerformingExcessPropertyChecks) {
63773
+ if (hasExcessProperties(source, target, reportErrors)) {
63774
+ if (reportErrors) {
63775
+ reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target);
63776
+ }
63777
+ return 0 /* False */;
63778
+ }
63779
+ }
63780
+ var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) &&
63781
+ source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType &&
63782
+ target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) &&
63783
+ (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
63784
+ var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */);
63785
+ if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
63779
63786
  if (reportErrors) {
63780
- reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target);
63787
+ var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source);
63788
+ var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
63789
+ var calls = getSignaturesOfType(source, 0 /* Call */);
63790
+ var constructs = getSignaturesOfType(source, 1 /* Construct */);
63791
+ if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) ||
63792
+ constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) {
63793
+ reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
63794
+ }
63795
+ else {
63796
+ reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString);
63797
+ }
63781
63798
  }
63782
63799
  return 0 /* False */;
63783
63800
  }
63784
- }
63785
- var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) &&
63786
- source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType &&
63787
- target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) &&
63788
- (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
63789
- if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
63790
- if (reportErrors) {
63791
- var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source);
63792
- var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
63793
- var calls = getSignaturesOfType(source, 0 /* Call */);
63794
- var constructs = getSignaturesOfType(source, 1 /* Construct */);
63795
- if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) ||
63796
- constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) {
63797
- reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
63798
- }
63799
- else {
63800
- reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString);
63801
- }
63801
+ traceUnionsOrIntersectionsTooLarge(source, target);
63802
+ var skipCaching = source.flags & 1048576 /* Union */ && source.types.length < 4 && !(target.flags & 1048576 /* Union */) ||
63803
+ target.flags & 1048576 /* Union */ && target.types.length < 4 && !(source.flags & 469499904 /* StructuredOrInstantiable */);
63804
+ var result_7 = skipCaching ?
63805
+ unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
63806
+ recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
63807
+ // For certain combinations involving intersections and optional, excess, or mismatched properties we need
63808
+ // an extra property check where the intersection is viewed as a single object. The following are motivating
63809
+ // examples that all should be errors, but aren't without this extra property check:
63810
+ //
63811
+ // let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
63812
+ //
63813
+ // declare let wrong: { a: { y: string } };
63814
+ // let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
63815
+ //
63816
+ // function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
63817
+ // x = y; // Mismatched property in source intersection
63818
+ // }
63819
+ //
63820
+ // We suppress recursive intersection property checks because they can generate lots of work when relating
63821
+ // recursive intersections that are structurally similar but not exactly identical. See #37854.
63822
+ if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
63823
+ 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 */); }))) {
63824
+ inPropertyCheck = true;
63825
+ result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
63826
+ inPropertyCheck = false;
63827
+ }
63828
+ if (result_7) {
63829
+ return result_7;
63802
63830
  }
63803
- return 0 /* False */;
63804
- }
63805
- traceUnionsOrIntersectionsTooLarge(source, target);
63806
- var result = 0 /* False */;
63807
- var saveErrorInfo = captureErrorCalculationState();
63808
- if ((source.flags & 1048576 /* Union */ || target.flags & 1048576 /* Union */) && getConstituentCount(source) * getConstituentCount(target) < 4) {
63809
- // We skip caching when source or target is a union with no more than three constituents.
63810
- result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */);
63811
63831
  }
63812
- else if (source.flags & 3145728 /* UnionOrIntersection */ || target.flags & 3145728 /* UnionOrIntersection */) {
63813
- result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */, recursionFlags);
63832
+ if (reportErrors) {
63833
+ reportErrorResults(originalSource, originalTarget, source, target, headMessage);
63814
63834
  }
63815
- if (!result && !(source.flags & 1048576 /* Union */) && (source.flags & (469499904 /* StructuredOrInstantiable */) || target.flags & 469499904 /* StructuredOrInstantiable */)) {
63816
- if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags)) {
63817
- resetErrorInfo(saveErrorInfo);
63835
+ return 0 /* False */;
63836
+ }
63837
+ function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
63838
+ var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
63839
+ var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
63840
+ source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
63841
+ target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
63842
+ var maybeSuppress = overrideNextErrorInfo > 0;
63843
+ if (maybeSuppress) {
63844
+ overrideNextErrorInfo--;
63845
+ }
63846
+ if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
63847
+ var currentError = errorInfo;
63848
+ tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ true);
63849
+ if (errorInfo !== currentError) {
63850
+ maybeSuppress = !!errorInfo;
63851
+ }
63852
+ }
63853
+ if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) {
63854
+ tryElaborateErrorsForPrimitivesAndObjects(source, target);
63855
+ }
63856
+ else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) {
63857
+ reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
63858
+ }
63859
+ else if (ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && target.flags & 2097152 /* Intersection */) {
63860
+ var targetTypes = target.types;
63861
+ var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
63862
+ var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
63863
+ if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
63864
+ (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
63865
+ // do not report top error
63866
+ return;
63818
63867
  }
63819
63868
  }
63820
- if (!result && source.flags & (2097152 /* Intersection */ | 262144 /* TypeParameter */)) {
63821
- // The combined constraint of an intersection type is the intersection of the constraints of
63822
- // the constituents. When an intersection type contains instantiable types with union type
63823
- // constraints, there are situations where we need to examine the combined constraint. One is
63824
- // when the target is a union type. Another is when the intersection contains types belonging
63825
- // to one of the disjoint domains. For example, given type variables T and U, each with the
63826
- // constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
63827
- // we need to check this constraint against a union on the target side. Also, given a type
63828
- // variable V constrained to 'string | number', 'V & number' has a combined constraint of
63829
- // 'string & number | number & number' which reduces to just 'number'.
63830
- // This also handles type parameters, as a type parameter with a union constraint compared against a union
63831
- // needs to have its constraint hoisted into an intersection with said type parameter, this way
63832
- // the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
63833
- // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
63834
- var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
63835
- if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) {
63836
- if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
63837
- // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
63838
- if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
63839
- resetErrorInfo(saveErrorInfo);
63840
- }
63841
- }
63842
- }
63869
+ else {
63870
+ errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
63843
63871
  }
63844
- // For certain combinations involving intersections and optional, excess, or mismatched properties we need
63845
- // an extra property check where the intersection is viewed as a single object. The following are motivating
63846
- // examples that all should be errors, but aren't without this extra property check:
63847
- //
63848
- // let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
63849
- //
63850
- // declare let wrong: { a: { y: string } };
63851
- // let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
63852
- //
63853
- // function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
63854
- // x = y; // Mismatched property in source intersection
63855
- // }
63856
- //
63857
- // We suppress recursive intersection property checks because they can generate lots of work when relating
63858
- // recursive intersections that are structurally similar but not exactly identical. See #37854.
63859
- if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
63860
- 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 */); }))) {
63861
- inPropertyCheck = true;
63862
- result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
63863
- inPropertyCheck = false;
63864
- }
63865
- reportErrorResults(source, target, result, isComparingJsxAttributes);
63866
- return result;
63867
- function reportErrorResults(source, target, result, isComparingJsxAttributes) {
63868
- if (!result && reportErrors) {
63869
- var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
63870
- var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
63871
- source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
63872
- target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
63873
- var maybeSuppress = overrideNextErrorInfo > 0;
63874
- if (maybeSuppress) {
63875
- overrideNextErrorInfo--;
63876
- }
63877
- if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
63878
- var currentError = errorInfo;
63879
- tryElaborateArrayLikeErrors(source, target, reportErrors);
63880
- if (errorInfo !== currentError) {
63881
- maybeSuppress = !!errorInfo;
63882
- }
63883
- }
63884
- if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) {
63885
- tryElaborateErrorsForPrimitivesAndObjects(source, target);
63886
- }
63887
- else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) {
63888
- reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
63889
- }
63890
- else if (isComparingJsxAttributes && target.flags & 2097152 /* Intersection */) {
63891
- var targetTypes = target.types;
63892
- var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
63893
- var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
63894
- if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
63895
- (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
63896
- // do not report top error
63897
- return result;
63898
- }
63899
- }
63900
- else {
63901
- errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
63902
- }
63903
- if (!headMessage && maybeSuppress) {
63904
- lastSkippedInfo = [source, target];
63905
- // Used by, eg, missing property checking to replace the top-level message with a more informative one
63906
- return result;
63907
- }
63908
- reportRelationError(headMessage, source, target);
63909
- }
63872
+ if (!headMessage && maybeSuppress) {
63873
+ lastSkippedInfo = [source, target];
63874
+ // Used by, eg, missing property checking to replace the top-level message with a more informative one
63875
+ return;
63910
63876
  }
63877
+ reportRelationError(headMessage, source, target);
63911
63878
  }
63912
63879
  function traceUnionsOrIntersectionsTooLarge(source, target) {
63913
63880
  if (!ts.tracing) {
@@ -63934,21 +63901,6 @@ var ts;
63934
63901
  }
63935
63902
  }
63936
63903
  }
63937
- function isIdenticalTo(source, target, recursionFlags) {
63938
- if (source.flags !== target.flags)
63939
- return 0 /* False */;
63940
- if (source.flags & 67358815 /* Singleton */)
63941
- return -1 /* True */;
63942
- traceUnionsOrIntersectionsTooLarge(source, target);
63943
- if (source.flags & 3145728 /* UnionOrIntersection */) {
63944
- var result_7 = eachTypeRelatedToSomeType(source, target);
63945
- if (result_7) {
63946
- result_7 &= eachTypeRelatedToSomeType(target, source);
63947
- }
63948
- return result_7;
63949
- }
63950
- return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
63951
- }
63952
63904
  function getTypeOfPropertyInTypes(types, name) {
63953
63905
  var appendPropType = function (propTypes, type) {
63954
63906
  var _a;
@@ -64047,6 +63999,41 @@ var ts;
64047
63999
  function shouldCheckAsExcessProperty(prop, container) {
64048
64000
  return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration;
64049
64001
  }
64002
+ function unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) {
64003
+ // Note that these checks are specifically ordered to produce correct results. In particular,
64004
+ // we need to deconstruct unions before intersections (because unions are always at the top),
64005
+ // and we need to handle "each" relations before "some" relations for the same kind of type.
64006
+ if (source.flags & 1048576 /* Union */) {
64007
+ return relation === comparableRelation ?
64008
+ someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState) :
64009
+ eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState);
64010
+ }
64011
+ if (target.flags & 1048576 /* Union */) {
64012
+ return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */));
64013
+ }
64014
+ if (target.flags & 2097152 /* Intersection */) {
64015
+ return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */);
64016
+ }
64017
+ // Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
64018
+ // constraints of all non-primitive types in the source into a new intersection. We do this because the
64019
+ // intersection may further constrain the constraints of the non-primitive types. For example, given a type
64020
+ // parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't
64021
+ // appear to be comparable to '2'.
64022
+ if (relation === comparableRelation && target.flags & 131068 /* Primitive */) {
64023
+ var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
64024
+ if (constraints !== source.types) {
64025
+ source = getIntersectionType(constraints);
64026
+ if (!(source.flags & 2097152 /* Intersection */)) {
64027
+ return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
64028
+ }
64029
+ }
64030
+ }
64031
+ // Check to see if any constituents of the intersection are immediately related to the target.
64032
+ // Don't report errors though. Elaborating on whether a source constituent is related to the target is
64033
+ // not actually useful and leads to some confusing error messages. Instead, we rely on the caller
64034
+ // checking whether the full intersection viewed as an object is related to the target.
64035
+ return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */);
64036
+ }
64050
64037
  function eachTypeRelatedToSomeType(source, target) {
64051
64038
  var result = -1 /* True */;
64052
64039
  var sourceTypes = source.types;
@@ -64082,8 +64069,11 @@ var ts;
64082
64069
  }
64083
64070
  }
64084
64071
  if (reportErrors) {
64072
+ // Elaborate only if we can find a best matching type in the target union
64085
64073
  var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
64086
- isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], 2 /* Target */, /*reportErrors*/ true);
64074
+ if (bestMatchingType) {
64075
+ isRelatedTo(source, bestMatchingType, 2 /* Target */, /*reportErrors*/ true);
64076
+ }
64087
64077
  }
64088
64078
  return 0 /* False */;
64089
64079
  }
@@ -64219,7 +64209,7 @@ var ts;
64219
64209
  if (overflow) {
64220
64210
  return 0 /* False */;
64221
64211
  }
64222
- var keyIntersectionState = intersectionState | (inPropertyCheck ? 16 /* InPropertyCheck */ : 0);
64212
+ var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* InPropertyCheck */ : 0);
64223
64213
  var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
64224
64214
  var entry = relation.get(id);
64225
64215
  if (entry !== undefined) {
@@ -64287,6 +64277,7 @@ var ts;
64287
64277
  return originalHandler(onlyUnreliable);
64288
64278
  };
64289
64279
  }
64280
+ var result;
64290
64281
  if (expandingFlags === 3 /* Both */) {
64291
64282
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", {
64292
64283
  sourceId: source.id,
@@ -64296,8 +64287,13 @@ var ts;
64296
64287
  depth: sourceDepth,
64297
64288
  targetDepth: targetDepth
64298
64289
  });
64290
+ result = 3 /* Maybe */;
64291
+ }
64292
+ else {
64293
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
64294
+ result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState);
64295
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
64299
64296
  }
64300
- var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 3 /* Maybe */;
64301
64297
  if (outofbandVarianceMarkerHandler) {
64302
64298
  outofbandVarianceMarkerHandler = originalHandler;
64303
64299
  }
@@ -64329,98 +64325,97 @@ var ts;
64329
64325
  return result;
64330
64326
  }
64331
64327
  function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
64332
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
64333
- var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState);
64334
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
64335
- return result;
64336
- }
64337
- function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) {
64338
64328
  if (intersectionState & 4 /* PropertyCheck */) {
64339
64329
  return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */);
64340
64330
  }
64341
- if (intersectionState & 8 /* UnionIntersectionCheck */) {
64342
- // Note that these checks are specifically ordered to produce correct results. In particular,
64343
- // we need to deconstruct unions before intersections (because unions are always at the top),
64344
- // and we need to handle "each" relations before "some" relations for the same kind of type.
64345
- if (source.flags & 1048576 /* Union */) {
64346
- return relation === comparableRelation ?
64347
- someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState & ~8 /* UnionIntersectionCheck */) :
64348
- eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState & ~8 /* UnionIntersectionCheck */);
64349
- }
64350
- if (target.flags & 1048576 /* Union */) {
64351
- return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */));
64352
- }
64353
- if (target.flags & 2097152 /* Intersection */) {
64354
- return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */);
64355
- }
64356
- // Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
64357
- // constraints of all non-primitive types in the source into a new intersection. We do this because the
64358
- // intersection may further constrain the constraints of the non-primitive types. For example, given a type
64359
- // parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't
64360
- // appear to be comparable to '2'.
64361
- if (relation === comparableRelation && target.flags & 131068 /* Primitive */) {
64362
- var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
64363
- if (constraints !== source.types) {
64364
- source = getIntersectionType(constraints);
64365
- if (!(source.flags & 2097152 /* Intersection */)) {
64366
- return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
64367
- }
64331
+ var result;
64332
+ var originalErrorInfo;
64333
+ var varianceCheckFailed = false;
64334
+ var saveErrorInfo = captureErrorCalculationState();
64335
+ var sourceFlags = source.flags;
64336
+ var targetFlags = target.flags;
64337
+ if (relation === identityRelation) {
64338
+ // We've already checked that source.flags and target.flags are identical
64339
+ if (sourceFlags & 3145728 /* UnionOrIntersection */) {
64340
+ var result_8 = eachTypeRelatedToSomeType(source, target);
64341
+ if (result_8) {
64342
+ result_8 &= eachTypeRelatedToSomeType(target, source);
64368
64343
  }
64344
+ return result_8;
64369
64345
  }
64370
- // Check to see if any constituents of the intersection are immediately related to the target.
64371
- //
64372
- // Don't report errors though. Checking whether a constituent is related to the source is not actually
64373
- // useful and leads to some confusing error messages. Instead it is better to let the below checks
64374
- // take care of this, or to not elaborate at all. For instance,
64375
- //
64376
- // - For an object type (such as 'C = A & B'), users are usually more interested in structural errors.
64377
- //
64378
- // - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection
64379
- // than to report that 'D' is not assignable to 'A' or 'B'.
64380
- //
64381
- // - For a primitive type or type parameter (such as 'number = A & B') there is no point in
64382
- // breaking the intersection apart.
64383
- return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */);
64384
- }
64385
- var flags = source.flags & target.flags;
64386
- if (relation === identityRelation && !(flags & 524288 /* Object */)) {
64387
- if (flags & 4194304 /* Index */) {
64346
+ if (sourceFlags & 4194304 /* Index */) {
64388
64347
  return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false);
64389
64348
  }
64390
- var result_8 = 0 /* False */;
64391
- if (flags & 8388608 /* IndexedAccess */) {
64392
- if (result_8 = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) {
64393
- if (result_8 &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) {
64394
- return result_8;
64349
+ if (sourceFlags & 8388608 /* IndexedAccess */) {
64350
+ if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) {
64351
+ if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) {
64352
+ return result;
64395
64353
  }
64396
64354
  }
64397
64355
  }
64398
- if (flags & 16777216 /* Conditional */) {
64356
+ if (sourceFlags & 16777216 /* Conditional */) {
64399
64357
  if (source.root.isDistributive === target.root.isDistributive) {
64400
- if (result_8 = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) {
64401
- if (result_8 &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) {
64402
- if (result_8 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
64403
- if (result_8 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
64404
- return result_8;
64358
+ if (result = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) {
64359
+ if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) {
64360
+ if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
64361
+ if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
64362
+ return result;
64405
64363
  }
64406
64364
  }
64407
64365
  }
64408
64366
  }
64409
64367
  }
64410
64368
  }
64411
- if (flags & 33554432 /* Substitution */) {
64369
+ if (sourceFlags & 33554432 /* Substitution */) {
64412
64370
  return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false);
64413
64371
  }
64414
- return 0 /* False */;
64372
+ if (!(sourceFlags & 524288 /* Object */)) {
64373
+ return 0 /* False */;
64374
+ }
64375
+ }
64376
+ else if (sourceFlags & 3145728 /* UnionOrIntersection */ || targetFlags & 3145728 /* UnionOrIntersection */) {
64377
+ if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) {
64378
+ return result;
64379
+ }
64380
+ if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) {
64381
+ // The combined constraint of an intersection type is the intersection of the constraints of
64382
+ // the constituents. When an intersection type contains instantiable types with union type
64383
+ // constraints, there are situations where we need to examine the combined constraint. One is
64384
+ // when the target is a union type. Another is when the intersection contains types belonging
64385
+ // to one of the disjoint domains. For example, given type variables T and U, each with the
64386
+ // constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
64387
+ // we need to check this constraint against a union on the target side. Also, given a type
64388
+ // variable V constrained to 'string | number', 'V & number' has a combined constraint of
64389
+ // 'string & number | number & number' which reduces to just 'number'.
64390
+ // This also handles type parameters, as a type parameter with a union constraint compared against a union
64391
+ // needs to have its constraint hoisted into an intersection with said type parameter, this way
64392
+ // the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
64393
+ // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
64394
+ var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
64395
+ if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
64396
+ // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
64397
+ if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
64398
+ resetErrorInfo(saveErrorInfo);
64399
+ return result;
64400
+ }
64401
+ }
64402
+ }
64403
+ // The ordered decomposition above doesn't handle all cases. Specifically, we also need to handle:
64404
+ // Source is instantiable (e.g. source has union or intersection constraint).
64405
+ // Source is an object, target is a union (e.g. { a, b: boolean } <=> { a, b: true } | { a, b: false }).
64406
+ // Source is an intersection, target is an object (e.g. { a } & { b } <=> { a, b }).
64407
+ // Source is an intersection, target is a union (e.g. { a } & { b: boolean } <=> { a, b: true } | { a, b: false }).
64408
+ // Source is an intersection, target instantiable (e.g. string & { tag } <=> T["a"] constrained to string & { tag }).
64409
+ if (!(sourceFlags & 465829888 /* Instantiable */ ||
64410
+ sourceFlags & 524288 /* Object */ && targetFlags & 1048576 /* Union */ ||
64411
+ sourceFlags & 2097152 /* Intersection */ && targetFlags & (524288 /* Object */ | 1048576 /* Union */ | 465829888 /* Instantiable */))) {
64412
+ return 0 /* False */;
64413
+ }
64415
64414
  }
64416
- var result;
64417
- var originalErrorInfo;
64418
- var varianceCheckFailed = false;
64419
- var saveErrorInfo = captureErrorCalculationState();
64420
64415
  // We limit alias variance probing to only object and conditional types since their alias behavior
64421
64416
  // is more predictable than other, interned types, which may or may not have an alias depending on
64422
64417
  // the order in which things were checked.
64423
- if (source.flags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol &&
64418
+ if (sourceFlags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol &&
64424
64419
  source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
64425
64420
  !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) {
64426
64421
  var variances = getAliasVariances(source.aliasSymbol);
@@ -64438,7 +64433,7 @@ var ts;
64438
64433
  isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) {
64439
64434
  return result;
64440
64435
  }
64441
- if (target.flags & 262144 /* TypeParameter */) {
64436
+ if (targetFlags & 262144 /* TypeParameter */) {
64442
64437
  // 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].
64443
64438
  if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) {
64444
64439
  if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) {
@@ -64450,10 +64445,10 @@ var ts;
64450
64445
  }
64451
64446
  }
64452
64447
  }
64453
- else if (target.flags & 4194304 /* Index */) {
64448
+ else if (targetFlags & 4194304 /* Index */) {
64454
64449
  var targetType_1 = target.type;
64455
64450
  // A keyof S is related to a keyof T if T is related to S.
64456
- if (source.flags & 4194304 /* Index */) {
64451
+ if (sourceFlags & 4194304 /* Index */) {
64457
64452
  if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) {
64458
64453
  return result;
64459
64454
  }
@@ -64504,8 +64499,8 @@ var ts;
64504
64499
  }
64505
64500
  }
64506
64501
  }
64507
- else if (target.flags & 8388608 /* IndexedAccess */) {
64508
- if (source.flags & 8388608 /* IndexedAccess */) {
64502
+ else if (targetFlags & 8388608 /* IndexedAccess */) {
64503
+ if (sourceFlags & 8388608 /* IndexedAccess */) {
64509
64504
  // Relate components directly before falling back to constraint relationships
64510
64505
  // A type S[K] is related to a type T[J] if S is related to T and K is related to J.
64511
64506
  if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) {
@@ -64611,7 +64606,7 @@ var ts;
64611
64606
  }
64612
64607
  }
64613
64608
  }
64614
- else if (target.flags & 16777216 /* Conditional */) {
64609
+ else if (targetFlags & 16777216 /* Conditional */) {
64615
64610
  // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
64616
64611
  // conditional type and bail out with a Ternary.Maybe result.
64617
64612
  if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
@@ -64636,8 +64631,8 @@ var ts;
64636
64631
  }
64637
64632
  }
64638
64633
  }
64639
- else if (target.flags & 134217728 /* TemplateLiteral */) {
64640
- if (source.flags & 134217728 /* TemplateLiteral */) {
64634
+ else if (targetFlags & 134217728 /* TemplateLiteral */) {
64635
+ if (sourceFlags & 134217728 /* TemplateLiteral */) {
64641
64636
  if (relation === comparableRelation) {
64642
64637
  return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */;
64643
64638
  }
@@ -64649,11 +64644,11 @@ var ts;
64649
64644
  return -1 /* True */;
64650
64645
  }
64651
64646
  }
64652
- if (source.flags & 8650752 /* TypeVariable */) {
64653
- // IndexedAccess comparisons are handled above in the `target.flags & TypeFlage.IndexedAccess` branch
64654
- if (!(source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */)) {
64647
+ if (sourceFlags & 8650752 /* TypeVariable */) {
64648
+ // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
64649
+ if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
64655
64650
  var constraint = getConstraintOfType(source);
64656
- if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
64651
+ if (!constraint || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
64657
64652
  // A type variable with no constraint is not related to the non-primitive object type.
64658
64653
  if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
64659
64654
  resetErrorInfo(saveErrorInfo);
@@ -64666,7 +64661,7 @@ var ts;
64666
64661
  return result;
64667
64662
  }
64668
64663
  // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
64669
- else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(target.flags & source.flags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
64664
+ else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
64670
64665
  resetErrorInfo(saveErrorInfo);
64671
64666
  return result;
64672
64667
  }
@@ -64683,14 +64678,14 @@ var ts;
64683
64678
  }
64684
64679
  }
64685
64680
  }
64686
- else if (source.flags & 4194304 /* Index */) {
64681
+ else if (sourceFlags & 4194304 /* Index */) {
64687
64682
  if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
64688
64683
  resetErrorInfo(saveErrorInfo);
64689
64684
  return result;
64690
64685
  }
64691
64686
  }
64692
- else if (source.flags & 134217728 /* TemplateLiteral */ && !(target.flags & 524288 /* Object */)) {
64693
- if (!(target.flags & 134217728 /* TemplateLiteral */)) {
64687
+ else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
64688
+ if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
64694
64689
  var constraint = getBaseConstraintOfType(source);
64695
64690
  if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
64696
64691
  resetErrorInfo(saveErrorInfo);
@@ -64698,8 +64693,8 @@ var ts;
64698
64693
  }
64699
64694
  }
64700
64695
  }
64701
- else if (source.flags & 268435456 /* StringMapping */) {
64702
- if (target.flags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
64696
+ else if (sourceFlags & 268435456 /* StringMapping */) {
64697
+ if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
64703
64698
  if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
64704
64699
  resetErrorInfo(saveErrorInfo);
64705
64700
  return result;
@@ -64713,14 +64708,14 @@ var ts;
64713
64708
  }
64714
64709
  }
64715
64710
  }
64716
- else if (source.flags & 16777216 /* Conditional */) {
64711
+ else if (sourceFlags & 16777216 /* Conditional */) {
64717
64712
  // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
64718
64713
  // conditional type and bail out with a Ternary.Maybe result.
64719
64714
  if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
64720
64715
  resetErrorInfo(saveErrorInfo);
64721
64716
  return 3 /* Maybe */;
64722
64717
  }
64723
- if (target.flags & 16777216 /* Conditional */) {
64718
+ if (targetFlags & 16777216 /* Conditional */) {
64724
64719
  // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
64725
64720
  // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
64726
64721
  // and Y1 is related to Y2.
@@ -64780,9 +64775,10 @@ var ts;
64780
64775
  }
64781
64776
  return 0 /* False */;
64782
64777
  }
64783
- var sourceIsPrimitive = !!(source.flags & 131068 /* Primitive */);
64778
+ var sourceIsPrimitive = !!(sourceFlags & 131068 /* Primitive */);
64784
64779
  if (relation !== identityRelation) {
64785
64780
  source = getApparentType(source);
64781
+ sourceFlags = source.flags;
64786
64782
  }
64787
64783
  else if (isGenericMappedType(source)) {
64788
64784
  return 0 /* False */;
@@ -64824,7 +64820,7 @@ var ts;
64824
64820
  // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates
64825
64821
  // to X. Failing both of those we want to check if the aggregation of A and B's members structurally
64826
64822
  // relates to X. Thus, we include intersection types on the source side here.
64827
- if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 524288 /* Object */) {
64823
+ if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 524288 /* Object */) {
64828
64824
  // Report structural errors only if we haven't reported any errors yet
64829
64825
  var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive;
64830
64826
  result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, intersectionState);
@@ -64848,7 +64844,7 @@ var ts;
64848
64844
  // there exists a constituent of T for every combination of the discriminants of S
64849
64845
  // with respect to T. We do not report errors here, as we will use the existing
64850
64846
  // error result from checking each constituent of the union.
64851
- if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 1048576 /* Union */) {
64847
+ if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 1048576 /* Union */) {
64852
64848
  var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */);
64853
64849
  if (objectOnlyTarget.flags & 1048576 /* Union */) {
64854
64850
  var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
@@ -65363,7 +65359,6 @@ var ts;
65363
65359
  }
65364
65360
  }
65365
65361
  var result = -1 /* True */;
65366
- var saveErrorInfo = captureErrorCalculationState();
65367
65362
  var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
65368
65363
  var sourceObjectFlags = ts.getObjectFlags(source);
65369
65364
  var targetObjectFlags = ts.getObjectFlags(target);
@@ -65404,6 +65399,7 @@ var ts;
65404
65399
  else {
65405
65400
  outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) {
65406
65401
  var t = targetSignatures_1[_i];
65402
+ var saveErrorInfo = captureErrorCalculationState();
65407
65403
  // Only elaborate errors from the first failure
65408
65404
  var shouldElaborateErrors = reportErrors;
65409
65405
  for (var _c = 0, sourceSignatures_1 = sourceSignatures; _c < sourceSignatures_1.length; _c++) {
@@ -68574,9 +68570,6 @@ var ts;
68574
68570
  getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) :
68575
68571
  mapType(type, mapper);
68576
68572
  }
68577
- function getConstituentCount(type) {
68578
- return type.flags & 1048576 /* Union */ ? type.types.length : 1;
68579
- }
68580
68573
  function extractTypesOfKind(type, kind) {
68581
68574
  return filterType(type, function (t) { return (t.flags & kind) !== 0; });
68582
68575
  }
@@ -70150,7 +70143,7 @@ var ts;
70150
70143
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
70151
70144
  someType(type, isGenericTypeWithUnionConstraint) &&
70152
70145
  (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
70153
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
70146
+ return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
70154
70147
  }
70155
70148
  function isExportOrExportExpression(location) {
70156
70149
  return !!ts.findAncestor(location, function (n) {
@@ -70222,6 +70215,9 @@ var ts;
70222
70215
  if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
70223
70216
  var pattern = declaration.parent;
70224
70217
  var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode);
70218
+ if (narrowedType.flags & 131072 /* Never */) {
70219
+ return neverType;
70220
+ }
70225
70221
  return getBindingElementTypeFromParentType(declaration, narrowedType);
70226
70222
  }
70227
70223
  }
@@ -76242,21 +76238,22 @@ var ts;
76242
76238
  if (links.type === unknownType) {
76243
76239
  links.type = getTypeFromBindingPattern(declaration.name);
76244
76240
  }
76245
- assignBindingElementTypes(declaration.name);
76241
+ assignBindingElementTypes(declaration.name, links.type);
76246
76242
  }
76247
76243
  }
76248
76244
  }
76249
76245
  // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push
76250
76246
  // the destructured type into the contained binding elements.
76251
- function assignBindingElementTypes(pattern) {
76247
+ function assignBindingElementTypes(pattern, parentType) {
76252
76248
  for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
76253
76249
  var element = _a[_i];
76254
76250
  if (!ts.isOmittedExpression(element)) {
76251
+ var type = getBindingElementTypeFromParentType(element, parentType);
76255
76252
  if (element.name.kind === 79 /* Identifier */) {
76256
- getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element);
76253
+ getSymbolLinks(getSymbolOfNode(element)).type = type;
76257
76254
  }
76258
76255
  else {
76259
- assignBindingElementTypes(element.name);
76256
+ assignBindingElementTypes(element.name, type);
76260
76257
  }
76261
76258
  }
76262
76259
  }
@@ -79997,28 +79994,24 @@ var ts;
79997
79994
  if (returnType.flags & 1 /* Any */) {
79998
79995
  return;
79999
79996
  }
79997
+ var headMessage;
80000
79998
  var expectedReturnType;
80001
- var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
80002
- var errorInfo;
80003
79999
  switch (node.parent.kind) {
80004
80000
  case 256 /* ClassDeclaration */:
80001
+ headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
80005
80002
  var classSymbol = getSymbolOfNode(node.parent);
80006
80003
  var classConstructorType = getTypeOfSymbol(classSymbol);
80007
80004
  expectedReturnType = getUnionType([classConstructorType, voidType]);
80008
80005
  break;
80009
- case 163 /* Parameter */:
80010
- expectedReturnType = voidType;
80011
- errorInfo = ts.chainDiagnosticMessages(
80012
- /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any);
80013
- break;
80014
80006
  case 166 /* PropertyDeclaration */:
80007
+ case 163 /* Parameter */:
80008
+ headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any;
80015
80009
  expectedReturnType = voidType;
80016
- errorInfo = ts.chainDiagnosticMessages(
80017
- /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any);
80018
80010
  break;
80019
80011
  case 168 /* MethodDeclaration */:
80020
80012
  case 171 /* GetAccessor */:
80021
80013
  case 172 /* SetAccessor */:
80014
+ headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
80022
80015
  var methodType = getTypeOfNode(node.parent);
80023
80016
  var descriptorType = createTypedPropertyDescriptorType(methodType);
80024
80017
  expectedReturnType = getUnionType([descriptorType, voidType]);
@@ -80026,7 +80019,7 @@ var ts;
80026
80019
  default:
80027
80020
  return ts.Debug.fail();
80028
80021
  }
80029
- checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, function () { return errorInfo; });
80022
+ checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage);
80030
80023
  }
80031
80024
  /**
80032
80025
  * If a TypeNode can be resolved to a value symbol imported from an external module, it is
@@ -82299,9 +82292,9 @@ var ts;
82299
82292
  var containsArguments = containsArgumentsReference(node);
82300
82293
  if (containsArguments) {
82301
82294
  var lastJSDocParam = ts.lastOrUndefined(jsdocParameters);
82302
- if (lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
82295
+ if (isJs && lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
82303
82296
  lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
82304
- 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));
82297
+ 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));
82305
82298
  }
82306
82299
  }
82307
82300
  else {
@@ -82311,7 +82304,9 @@ var ts;
82311
82304
  return;
82312
82305
  }
82313
82306
  if (ts.isQualifiedName(name)) {
82314
- errorOrSuggestion(isJs, name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
82307
+ if (isJs) {
82308
+ error(name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
82309
+ }
82315
82310
  }
82316
82311
  else {
82317
82312
  errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
@@ -87490,28 +87485,27 @@ var ts;
87490
87485
  }
87491
87486
  function findMostOverlappyType(source, unionTarget) {
87492
87487
  var bestMatch;
87493
- var matchingCount = 0;
87494
- for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
87495
- var target = _a[_i];
87496
- var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
87497
- if (overlap.flags & 4194304 /* Index */) {
87498
- // perfect overlap of keys
87499
- bestMatch = target;
87500
- matchingCount = Infinity;
87501
- }
87502
- else if (overlap.flags & 1048576 /* Union */) {
87503
- // We only want to account for literal types otherwise.
87504
- // If we have a union of index types, it seems likely that we
87505
- // needed to elaborate between two generic mapped types anyway.
87506
- var len = ts.length(ts.filter(overlap.types, isUnitType));
87507
- if (len >= matchingCount) {
87508
- bestMatch = target;
87509
- matchingCount = len;
87510
- }
87511
- }
87512
- else if (isUnitType(overlap) && 1 >= matchingCount) {
87513
- bestMatch = target;
87514
- matchingCount = 1;
87488
+ if (!(source.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) {
87489
+ var matchingCount = 0;
87490
+ for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
87491
+ var target = _a[_i];
87492
+ if (!(target.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) {
87493
+ var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
87494
+ if (overlap.flags & 4194304 /* Index */) {
87495
+ // perfect overlap of keys
87496
+ return target;
87497
+ }
87498
+ else if (isUnitType(overlap) || overlap.flags & 1048576 /* Union */) {
87499
+ // We only want to account for literal types otherwise.
87500
+ // If we have a union of index types, it seems likely that we
87501
+ // needed to elaborate between two generic mapped types anyway.
87502
+ var len = overlap.flags & 1048576 /* Union */ ? ts.countWhere(overlap.types, isUnitType) : 1;
87503
+ if (len >= matchingCount) {
87504
+ bestMatch = target;
87505
+ matchingCount = len;
87506
+ }
87507
+ }
87508
+ }
87515
87509
  }
87516
87510
  }
87517
87511
  return bestMatch;
@@ -140621,6 +140615,41 @@ var ts;
140621
140615
  if (ts.scanner.getToken() === 1 /* EndOfFileToken */) {
140622
140616
  break;
140623
140617
  }
140618
+ if (ts.scanner.getToken() === 15 /* TemplateHead */) {
140619
+ var stack = [ts.scanner.getToken()];
140620
+ var token = ts.scanner.scan();
140621
+ loop: while (ts.length(stack)) {
140622
+ switch (token) {
140623
+ case 1 /* EndOfFileToken */:
140624
+ break loop;
140625
+ case 100 /* ImportKeyword */:
140626
+ tryConsumeImport();
140627
+ break;
140628
+ case 15 /* TemplateHead */:
140629
+ stack.push(token);
140630
+ break;
140631
+ case 18 /* OpenBraceToken */:
140632
+ if (ts.length(stack)) {
140633
+ stack.push(token);
140634
+ }
140635
+ break;
140636
+ case 19 /* CloseBraceToken */:
140637
+ if (ts.length(stack)) {
140638
+ if (ts.lastOrUndefined(stack) === 15 /* TemplateHead */) {
140639
+ if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* TemplateTail */) {
140640
+ stack.pop();
140641
+ }
140642
+ }
140643
+ else {
140644
+ stack.pop();
140645
+ }
140646
+ }
140647
+ break;
140648
+ }
140649
+ token = ts.scanner.scan();
140650
+ }
140651
+ nextToken();
140652
+ }
140624
140653
  // check if at least one of alternative have moved scanner forward
140625
140654
  if (tryConsumeDeclare() ||
140626
140655
  tryConsumeImport() ||
@@ -157428,7 +157457,7 @@ var ts;
157428
157457
  // cannot find either start or end node
157429
157458
  return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
157430
157459
  }
157431
- if (ts.isJSDoc(start)) {
157460
+ if (start.flags & 4194304 /* JSDoc */) {
157432
157461
  return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] };
157433
157462
  }
157434
157463
  if (start.parent !== end.parent) {