@typescript-deploys/pr-build 4.6.0-pr-47337-6 → 4.6.0-pr-47550-8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-insiders.20220121";
103
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220124";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -111,13 +111,18 @@ var ts;
111
111
  /* @internal */
112
112
  var NativeCollections;
113
113
  (function (NativeCollections) {
114
+ var globals = typeof globalThis !== "undefined" ? globalThis :
115
+ typeof global !== "undefined" ? global :
116
+ typeof self !== "undefined" ? self :
117
+ undefined;
114
118
  /**
115
119
  * Returns the native Map implementation if it is available and compatible (i.e. supports iteration).
116
120
  */
117
121
  function tryGetNativeMap() {
118
122
  // Internet Explorer's Map doesn't support iteration, so don't use it.
123
+ var gMap = globals === null || globals === void 0 ? void 0 : globals.Map;
119
124
  // eslint-disable-next-line no-in-operator
120
- return typeof Map !== "undefined" && "entries" in Map.prototype && new Map([[0, 0]]).size === 1 ? Map : undefined;
125
+ return typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
121
126
  }
122
127
  NativeCollections.tryGetNativeMap = tryGetNativeMap;
123
128
  /**
@@ -125,8 +130,9 @@ var ts;
125
130
  */
126
131
  function tryGetNativeSet() {
127
132
  // Internet Explorer's Set doesn't support iteration, so don't use it.
133
+ var gSet = globals === null || globals === void 0 ? void 0 : globals.Set;
128
134
  // eslint-disable-next-line no-in-operator
129
- return typeof Set !== "undefined" && "entries" in Set.prototype && new Set([0]).size === 1 ? Set : undefined;
135
+ return typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
130
136
  }
131
137
  NativeCollections.tryGetNativeSet = tryGetNativeSet;
132
138
  })(NativeCollections || (NativeCollections = {}));
@@ -33366,7 +33372,7 @@ var ts;
33366
33372
  function parseInitializer() {
33367
33373
  return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined;
33368
33374
  }
33369
- function parseAssignmentExpressionOrHigher() {
33375
+ function parseAssignmentExpressionOrHigher(parsingConditionalExpression) {
33370
33376
  // AssignmentExpression[in,yield]:
33371
33377
  // 1) ConditionalExpression[?in,?yield]
33372
33378
  // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
@@ -33392,7 +33398,7 @@ var ts;
33392
33398
  // If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
33393
33399
  // not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
33394
33400
  // with AssignmentExpression if we see one.
33395
- var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
33401
+ var arrowExpression = tryParseParenthesizedArrowFunctionExpression(parsingConditionalExpression) || tryParseAsyncSimpleArrowFunctionExpression();
33396
33402
  if (arrowExpression) {
33397
33403
  return arrowExpression;
33398
33404
  }
@@ -33411,7 +33417,7 @@ var ts;
33411
33417
  // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single
33412
33418
  // identifier and the current token is an arrow.
33413
33419
  if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) {
33414
- return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined);
33420
+ return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined, parsingConditionalExpression);
33415
33421
  }
33416
33422
  // Now see if we might be in cases '2' or '3'.
33417
33423
  // If the expression was a LHS expression, and we have an assignment operator, then
@@ -33471,7 +33477,7 @@ var ts;
33471
33477
  return finishNode(factory.createYieldExpression(/*asteriskToken*/ undefined, /*expression*/ undefined), pos);
33472
33478
  }
33473
33479
  }
33474
- function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) {
33480
+ function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier, parsingConditionalExpression) {
33475
33481
  ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
33476
33482
  var parameter = factory.createParameterDeclaration(
33477
33483
  /*decorators*/ undefined,
@@ -33483,11 +33489,11 @@ var ts;
33483
33489
  finishNode(parameter, identifier.pos);
33484
33490
  var parameters = createNodeArray([parameter], parameter.pos, parameter.end);
33485
33491
  var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
33486
- var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier);
33492
+ var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, parsingConditionalExpression);
33487
33493
  var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body);
33488
33494
  return addJSDocComment(finishNode(node, pos));
33489
33495
  }
33490
- function tryParseParenthesizedArrowFunctionExpression() {
33496
+ function tryParseParenthesizedArrowFunctionExpression(parsingConditionalExpression) {
33491
33497
  var triState = isParenthesizedArrowFunctionExpression();
33492
33498
  if (triState === 0 /* False */) {
33493
33499
  // It's definitely not a parenthesized arrow function expression.
@@ -33498,8 +33504,8 @@ var ts;
33498
33504
  // it out, but don't allow any ambiguity, and return 'undefined' if this could be an
33499
33505
  // expression instead.
33500
33506
  return triState === 1 /* True */ ?
33501
- parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) :
33502
- tryParse(parsePossibleParenthesizedArrowFunctionExpression);
33507
+ parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, parsingConditionalExpression) :
33508
+ tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(parsingConditionalExpression); });
33503
33509
  }
33504
33510
  // True -> We definitely expect a parenthesized arrow function here.
33505
33511
  // False -> There *cannot* be a parenthesized arrow function here.
@@ -33629,25 +33635,25 @@ var ts;
33629
33635
  return 2 /* Unknown */;
33630
33636
  }
33631
33637
  }
33632
- function parsePossibleParenthesizedArrowFunctionExpression() {
33638
+ function parsePossibleParenthesizedArrowFunctionExpression(parsingConditionalExpression) {
33633
33639
  var tokenPos = scanner.getTokenPos();
33634
33640
  if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) {
33635
33641
  return undefined;
33636
33642
  }
33637
- var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false);
33643
+ var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false, parsingConditionalExpression);
33638
33644
  if (!result) {
33639
33645
  (notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos);
33640
33646
  }
33641
33647
  return result;
33642
33648
  }
33643
- function tryParseAsyncSimpleArrowFunctionExpression() {
33649
+ function tryParseAsyncSimpleArrowFunctionExpression(parsingConditionalExpression) {
33644
33650
  // We do a check here so that we won't be doing unnecessarily call to "lookAhead"
33645
33651
  if (token() === 131 /* AsyncKeyword */) {
33646
33652
  if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) {
33647
33653
  var pos = getNodePos();
33648
33654
  var asyncModifier = parseModifiersForArrowFunction();
33649
33655
  var expr = parseBinaryExpressionOrHigher(0 /* Lowest */);
33650
- return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier);
33656
+ return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier, parsingConditionalExpression);
33651
33657
  }
33652
33658
  }
33653
33659
  return undefined;
@@ -33671,7 +33677,7 @@ var ts;
33671
33677
  }
33672
33678
  return 0 /* False */;
33673
33679
  }
33674
- function parseParenthesizedArrowFunctionExpression(allowAmbiguity) {
33680
+ function parseParenthesizedArrowFunctionExpression(allowAmbiguity, parsingConditionalExpression) {
33675
33681
  var pos = getNodePos();
33676
33682
  var hasJSDoc = hasPrecedingJSDocComment();
33677
33683
  var modifiers = parseModifiersForArrowFunction();
@@ -33697,6 +33703,20 @@ var ts;
33697
33703
  return undefined;
33698
33704
  }
33699
33705
  }
33706
+ // Given:
33707
+ // x ? y => ({ y }) : z => ({ z })
33708
+ // We try to parse the body of the first arrow function by looking at:
33709
+ // ({ y }) : z => ({ z })
33710
+ // This is a valid arrow function with "z" as the return type.
33711
+ //
33712
+ // But, if we're in the true side of a conditional expression, this colon
33713
+ // terminates the true side, so cannot be the return type. If we are in the
33714
+ // false side, we may still be within the true side of a parent conditional
33715
+ // expression, so don't allow it to be a return type either.
33716
+ if (parsingConditionalExpression && token() === 58 /* ColonToken */) {
33717
+ ts.Debug.assert(!allowAmbiguity);
33718
+ return undefined;
33719
+ }
33700
33720
  var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
33701
33721
  if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
33702
33722
  return undefined;
@@ -33730,7 +33750,7 @@ var ts;
33730
33750
  var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
33731
33751
  return withJSDoc(finishNode(node, pos), hasJSDoc);
33732
33752
  }
33733
- function parseArrowFunctionExpressionBody(isAsync) {
33753
+ function parseArrowFunctionExpressionBody(isAsync, parsingConditionalExpression) {
33734
33754
  if (token() === 18 /* OpenBraceToken */) {
33735
33755
  return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */);
33736
33756
  }
@@ -33758,8 +33778,8 @@ var ts;
33758
33778
  var savedTopLevel = topLevel;
33759
33779
  topLevel = false;
33760
33780
  var node = isAsync
33761
- ? doInAwaitContext(parseAssignmentExpressionOrHigher)
33762
- : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
33781
+ ? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(parsingConditionalExpression); })
33782
+ : doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(parsingConditionalExpression); });
33763
33783
  topLevel = savedTopLevel;
33764
33784
  return node;
33765
33785
  }
@@ -33772,8 +33792,8 @@ var ts;
33772
33792
  // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and
33773
33793
  // we do not that for the 'whenFalse' part.
33774
33794
  var colonToken;
33775
- return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
33776
- ? parseAssignmentExpressionOrHigher()
33795
+ return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*parsingConditionalExpression*/ true); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
33796
+ ? parseAssignmentExpressionOrHigher(/*parsingConditionalExpression*/ true)
33777
33797
  : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos);
33778
33798
  }
33779
33799
  function parseBinaryExpressionOrHigher(precedence) {
@@ -46788,6 +46808,9 @@ var ts;
46788
46808
  TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts";
46789
46809
  TypeFacts[TypeFacts["AllTypeofNE"] = 556800] = "AllTypeofNE";
46790
46810
  TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts";
46811
+ // Masks
46812
+ TypeFacts[TypeFacts["OrFactsMask"] = 8288] = "OrFactsMask";
46813
+ TypeFacts[TypeFacts["AndFactsMask"] = 16768927] = "AndFactsMask";
46791
46814
  })(TypeFacts || (TypeFacts = {}));
46792
46815
  var typeofEQFacts = new ts.Map(ts.getEntries({
46793
46816
  string: 1 /* TypeofEQString */,
@@ -46828,10 +46851,6 @@ var ts;
46828
46851
  CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive";
46829
46852
  CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
46830
46853
  CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
46831
- CheckMode[CheckMode["ObjectRestBindingElement"] = 32] = "ObjectRestBindingElement";
46832
- // e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
46833
- // we need to preserve generic types instead of substituting them for constraints
46834
- CheckMode[CheckMode["IncludeOptionality"] = 64] = "IncludeOptionality";
46835
46854
  })(CheckMode || (CheckMode = {}));
46836
46855
  var SignatureCheckMode;
46837
46856
  (function (SignatureCheckMode) {
@@ -54256,12 +54275,9 @@ var ts;
54256
54275
  }
54257
54276
  // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
54258
54277
  // assigned by contextual typing.
54259
- function getTypeForBindingElementParent(node, checkMode) {
54260
- if (checkMode && checkMode !== 0 /* Normal */) {
54261
- return getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode);
54262
- }
54278
+ function getTypeForBindingElementParent(node) {
54263
54279
  var symbol = getSymbolOfNode(node);
54264
- return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode);
54280
+ return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false);
54265
54281
  }
54266
54282
  function getRestType(source, properties, symbol) {
54267
54283
  source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); });
@@ -54379,8 +54395,7 @@ var ts;
54379
54395
  }
54380
54396
  /** Return the inferred type for a binding element */
54381
54397
  function getTypeForBindingElement(declaration) {
54382
- var checkMode = declaration.dotDotDotToken && declaration.parent.kind !== 201 /* ArrayBindingPattern */ ? 32 /* ObjectRestBindingElement */ : 0 /* Normal */;
54383
- var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
54398
+ var parentType = getTypeForBindingElementParent(declaration.parent.parent);
54384
54399
  return parentType && getBindingElementTypeFromParentType(declaration, parentType);
54385
54400
  }
54386
54401
  function getBindingElementTypeFromParentType(declaration, parentType) {
@@ -54452,9 +54467,9 @@ var ts;
54452
54467
  if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
54453
54468
  // In strict null checking mode, if a default value of a non-undefined type is specified, remove
54454
54469
  // undefined from the final type.
54455
- return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, /* checkMode */ undefined)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
54470
+ return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
54456
54471
  }
54457
- return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, /* checkMode */ undefined)], 2 /* Subtype */));
54472
+ return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2 /* Subtype */));
54458
54473
  }
54459
54474
  function getTypeForDeclarationFromJSDocComment(declaration) {
54460
54475
  var jsdocType = ts.getJSDocType(declaration);
@@ -54477,12 +54492,11 @@ var ts;
54477
54492
  return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type;
54478
54493
  }
54479
54494
  // Return the inferred type for a variable, parameter, or property declaration
54480
- function getTypeForVariableLikeDeclaration(declaration, includeOptionality, // >> TODO: change this to use a flag in check mode; figure out how this interacts with caching
54481
- checkMode) {
54495
+ function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
54482
54496
  // A variable declared in a for..in statement is of type string, or of type keyof T when the
54483
54497
  // right hand expression is of a type parameter type.
54484
54498
  if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 242 /* ForInStatement */) {
54485
- var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, /*checkMode*/ checkMode)));
54499
+ var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression)));
54486
54500
  return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType;
54487
54501
  }
54488
54502
  if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForOfStatement */) {
@@ -54559,7 +54573,7 @@ var ts;
54559
54573
  return containerObjectType;
54560
54574
  }
54561
54575
  }
54562
- var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration, checkMode));
54576
+ var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration));
54563
54577
  return addOptionality(type, isProperty, isOptional);
54564
54578
  }
54565
54579
  if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) {
@@ -54931,7 +54945,7 @@ var ts;
54931
54945
  // contextual type or, if the element itself is a binding pattern, with the type implied by that binding
54932
54946
  // pattern.
54933
54947
  var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType;
54934
- return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, /*checkMode*/ undefined, contextualType)));
54948
+ return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, contextualType)));
54935
54949
  }
54936
54950
  if (ts.isBindingPattern(element.name)) {
54937
54951
  return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
@@ -55020,7 +55034,7 @@ var ts;
55020
55034
  // binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the
55021
55035
  // tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string.
55022
55036
  function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
55023
- return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, /*checkMode*/ undefined), declaration, reportErrors);
55037
+ return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true), declaration, reportErrors);
55024
55038
  }
55025
55039
  function isGlobalSymbolConstructor(node) {
55026
55040
  var symbol = getSymbolOfNode(node);
@@ -67938,10 +67952,23 @@ var ts;
67938
67952
  // When an intersection contains a primitive type we ignore object type constituents as they are
67939
67953
  // presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type.
67940
67954
  ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */));
67941
- return ts.reduceLeft(type.types, function (facts, t) { return facts & getTypeFacts(t, ignoreObjects); }, 16777215 /* All */);
67955
+ return getIntersectionTypeFacts(type, ignoreObjects);
67942
67956
  }
67943
67957
  return 16777215 /* All */;
67944
67958
  }
67959
+ function getIntersectionTypeFacts(type, ignoreObjects) {
67960
+ // When computing the type facts of an intersection type, certain type facts are computed as `and`
67961
+ // and others are computed as `or`.
67962
+ var oredFacts = 0 /* None */;
67963
+ var andedFacts = 16777215 /* All */;
67964
+ for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
67965
+ var t = _a[_i];
67966
+ var f = getTypeFacts(t, ignoreObjects);
67967
+ oredFacts |= f;
67968
+ andedFacts &= f;
67969
+ }
67970
+ return oredFacts & 8288 /* OrFactsMask */ | andedFacts & 16768927 /* AndFactsMask */;
67971
+ }
67945
67972
  function getTypeWithFacts(type, include) {
67946
67973
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
67947
67974
  }
@@ -69766,16 +69793,12 @@ var ts;
69766
69793
  function isGenericTypeWithoutNullableConstraint(type) {
69767
69794
  return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
69768
69795
  }
69769
- function hasContextualTypeWithNoGenericTypes(node, checkMode) {
69796
+ function hasNonBindingPatternContextualTypeWithNoGenericTypes(node) {
69770
69797
  // Computing the contextual type for a child of a JSX element involves resolving the type of the
69771
69798
  // element's tag name, so we exclude that here to avoid circularities.
69772
- // If check mode has `CheckMode.ObjectRestBindingElement`, we skip binding pattern contextual types,
69773
- // as we want the type of a rest element to be generic when possible.
69774
69799
  var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
69775
69800
  !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
69776
- (checkMode && checkMode & 32 /* ObjectRestBindingElement */ ?
69777
- getContextualType(node, 8 /* SkipBindingPatterns */)
69778
- : getContextualType(node));
69801
+ getContextualType(node, 8 /* SkipBindingPatterns */);
69779
69802
  return contextualType && !isGenericType(contextualType);
69780
69803
  }
69781
69804
  function getNarrowableTypeForReference(type, reference, checkMode) {
@@ -69788,7 +69811,7 @@ var ts;
69788
69811
  // 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'.
69789
69812
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
69790
69813
  someType(type, isGenericTypeWithUnionConstraint) &&
69791
- (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
69814
+ (isConstraintPosition(type, reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference));
69792
69815
  return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
69793
69816
  }
69794
69817
  function isExportOrExportExpression(location) {
@@ -69856,7 +69879,7 @@ var ts;
69856
69879
  var links = getNodeLinks(location);
69857
69880
  if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
69858
69881
  links.flags |= 268435456 /* InCheckIdentifier */;
69859
- var parentType = getTypeForBindingElementParent(parent, /*checkMode*/ undefined);
69882
+ var parentType = getTypeForBindingElementParent(parent);
69860
69883
  links.flags &= ~268435456 /* InCheckIdentifier */;
69861
69884
  if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
69862
69885
  var pattern = declaration.parent;
@@ -70706,7 +70729,7 @@ var ts;
70706
70729
  var parent = declaration.parent.parent;
70707
70730
  var name = declaration.propertyName || declaration.name;
70708
70731
  var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
70709
- parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken && declaration.parent.kind !== 201 /* ArrayBindingPattern */ ? 32 /* ObjectRestBindingElement */ : 0 /* Normal */);
70732
+ parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent);
70710
70733
  if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
70711
70734
  return undefined;
70712
70735
  if (parent.name.kind === 201 /* ArrayBindingPattern */) {
@@ -75884,7 +75907,7 @@ var ts;
75884
75907
  var links = getSymbolLinks(parameter);
75885
75908
  if (!links.type) {
75886
75909
  var declaration = parameter.valueDeclaration;
75887
- links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true);
75910
+ links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true);
75888
75911
  if (declaration.name.kind !== 79 /* Identifier */) {
75889
75912
  // if inference didn't come up with anything but unknown, fall back to the binding pattern if present.
75890
75913
  if (links.type === unknownType) {
@@ -77615,11 +77638,11 @@ var ts;
77615
77638
  }
77616
77639
  }
77617
77640
  function checkExpressionCached(node, checkMode) {
77618
- if (checkMode && checkMode !== 0 /* Normal */) {
77619
- return checkExpression(node, checkMode);
77620
- }
77621
77641
  var links = getNodeLinks(node);
77622
77642
  if (!links.resolvedType) {
77643
+ if (checkMode && checkMode !== 0 /* Normal */) {
77644
+ return checkExpression(node, checkMode);
77645
+ }
77623
77646
  // When computing a type that we're going to cache, we need to ignore any ongoing control flow
77624
77647
  // analysis because variables may have transient types in indeterminable states. Moving flowLoopStart
77625
77648
  // to the top of the stack ensures all transient types are computed from a known point.
@@ -77639,12 +77662,10 @@ var ts;
77639
77662
  node.kind === 228 /* AsExpression */ ||
77640
77663
  ts.isJSDocTypeAssertion(node);
77641
77664
  }
77642
- function checkDeclarationInitializer(declaration, checkMode, contextualType) {
77665
+ function checkDeclarationInitializer(declaration, contextualType) {
77643
77666
  var initializer = ts.getEffectiveInitializer(declaration);
77644
77667
  var type = getQuickTypeOfExpression(initializer) ||
77645
- (contextualType ?
77646
- checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* Normal */)
77647
- : checkExpressionCached(initializer, checkMode));
77668
+ (contextualType ? checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, 0 /* Normal */) : checkExpressionCached(initializer));
77648
77669
  return ts.isParameter(declaration) && declaration.name.kind === 201 /* ArrayBindingPattern */ &&
77649
77670
  isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
77650
77671
  padTupleType(type, declaration.name) : type;
@@ -80584,8 +80605,7 @@ var ts;
80584
80605
  }
80585
80606
  // check private/protected variable access
80586
80607
  var parent = node.parent.parent;
80587
- var parentCheckMode = node.dotDotDotToken && node.parent.kind !== 201 /* ArrayBindingPattern */ ? 32 /* ObjectRestBindingElement */ : 0 /* Normal */;
80588
- var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
80608
+ var parentType = getTypeForBindingElementParent(parent);
80589
80609
  var name = node.propertyName || node.name;
80590
80610
  if (parentType && !ts.isBindingPattern(name)) {
80591
80611
  var exprType = getLiteralTypeFromPropertyName(name);
@@ -81824,7 +81844,7 @@ var ts;
81824
81844
  var declaration = catchClause.variableDeclaration;
81825
81845
  var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration));
81826
81846
  if (typeNode) {
81827
- var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, /*checkMode*/ undefined);
81847
+ var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false);
81828
81848
  if (type && !(type.flags & 3 /* AnyOrUnknown */)) {
81829
81849
  grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified);
81830
81850
  }
@@ -84510,7 +84530,7 @@ var ts;
84510
84530
  return errorType;
84511
84531
  }
84512
84532
  if (ts.isBindingPattern(node)) {
84513
- return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, /*checkMode*/ undefined) || errorType;
84533
+ return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true) || errorType;
84514
84534
  }
84515
84535
  if (isInRightSideOfImportOrExportAssignment(node)) {
84516
84536
  var symbol = getSymbolAtLocation(node);