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

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/tsc.js CHANGED
@@ -26926,18 +26926,18 @@ var ts;
26926
26926
  function parseInitializer() {
26927
26927
  return parseOptional(63) ? parseAssignmentExpressionOrHigher() : undefined;
26928
26928
  }
26929
- function parseAssignmentExpressionOrHigher() {
26929
+ function parseAssignmentExpressionOrHigher(parsingConditionalTrueSide) {
26930
26930
  if (isYieldExpression()) {
26931
26931
  return parseYieldExpression();
26932
26932
  }
26933
- var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
26933
+ var arrowExpression = tryParseParenthesizedArrowFunctionExpression(parsingConditionalTrueSide) || tryParseAsyncSimpleArrowFunctionExpression();
26934
26934
  if (arrowExpression) {
26935
26935
  return arrowExpression;
26936
26936
  }
26937
26937
  var pos = getNodePos();
26938
26938
  var expr = parseBinaryExpressionOrHigher(0);
26939
26939
  if (expr.kind === 79 && token() === 38) {
26940
- return parseSimpleArrowFunctionExpression(pos, expr, undefined);
26940
+ return parseSimpleArrowFunctionExpression(pos, expr, undefined, parsingConditionalTrueSide);
26941
26941
  }
26942
26942
  if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) {
26943
26943
  return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos);
@@ -26968,24 +26968,24 @@ var ts;
26968
26968
  return finishNode(factory.createYieldExpression(undefined, undefined), pos);
26969
26969
  }
26970
26970
  }
26971
- function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) {
26971
+ function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier, parsingConditionalTrueSide) {
26972
26972
  ts.Debug.assert(token() === 38, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
26973
26973
  var parameter = factory.createParameterDeclaration(undefined, undefined, undefined, identifier, undefined, undefined, undefined);
26974
26974
  finishNode(parameter, identifier.pos);
26975
26975
  var parameters = createNodeArray([parameter], parameter.pos, parameter.end);
26976
26976
  var equalsGreaterThanToken = parseExpectedToken(38);
26977
- var body = parseArrowFunctionExpressionBody(!!asyncModifier);
26977
+ var body = parseArrowFunctionExpressionBody(!!asyncModifier, parsingConditionalTrueSide);
26978
26978
  var node = factory.createArrowFunction(asyncModifier, undefined, parameters, undefined, equalsGreaterThanToken, body);
26979
26979
  return addJSDocComment(finishNode(node, pos));
26980
26980
  }
26981
- function tryParseParenthesizedArrowFunctionExpression() {
26981
+ function tryParseParenthesizedArrowFunctionExpression(parsingConditionalTrueSide) {
26982
26982
  var triState = isParenthesizedArrowFunctionExpression();
26983
26983
  if (triState === 0) {
26984
26984
  return undefined;
26985
26985
  }
26986
26986
  return triState === 1 ?
26987
- parseParenthesizedArrowFunctionExpression(true) :
26988
- tryParse(parsePossibleParenthesizedArrowFunctionExpression);
26987
+ parseParenthesizedArrowFunctionExpression(true, parsingConditionalTrueSide) :
26988
+ tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(parsingConditionalTrueSide); });
26989
26989
  }
26990
26990
  function isParenthesizedArrowFunctionExpression() {
26991
26991
  if (token() === 20 || token() === 29 || token() === 131) {
@@ -27079,24 +27079,24 @@ var ts;
27079
27079
  return 2;
27080
27080
  }
27081
27081
  }
27082
- function parsePossibleParenthesizedArrowFunctionExpression() {
27082
+ function parsePossibleParenthesizedArrowFunctionExpression(parsingConditionalTrueSide) {
27083
27083
  var tokenPos = scanner.getTokenPos();
27084
27084
  if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) {
27085
27085
  return undefined;
27086
27086
  }
27087
- var result = parseParenthesizedArrowFunctionExpression(false);
27087
+ var result = parseParenthesizedArrowFunctionExpression(false, parsingConditionalTrueSide);
27088
27088
  if (!result) {
27089
27089
  (notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos);
27090
27090
  }
27091
27091
  return result;
27092
27092
  }
27093
- function tryParseAsyncSimpleArrowFunctionExpression() {
27093
+ function tryParseAsyncSimpleArrowFunctionExpression(parsingConditionalTrueSide) {
27094
27094
  if (token() === 131) {
27095
27095
  if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1) {
27096
27096
  var pos = getNodePos();
27097
27097
  var asyncModifier = parseModifiersForArrowFunction();
27098
27098
  var expr = parseBinaryExpressionOrHigher(0);
27099
- return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier);
27099
+ return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier, parsingConditionalTrueSide);
27100
27100
  }
27101
27101
  }
27102
27102
  return undefined;
@@ -27114,7 +27114,7 @@ var ts;
27114
27114
  }
27115
27115
  return 0;
27116
27116
  }
27117
- function parseParenthesizedArrowFunctionExpression(allowAmbiguity) {
27117
+ function parseParenthesizedArrowFunctionExpression(allowAmbiguity, parsingConditionalTrueSide) {
27118
27118
  var pos = getNodePos();
27119
27119
  var hasJSDoc = hasPrecedingJSDocComment();
27120
27120
  var modifiers = parseModifiersForArrowFunction();
@@ -27133,6 +27133,10 @@ var ts;
27133
27133
  return undefined;
27134
27134
  }
27135
27135
  }
27136
+ if (parsingConditionalTrueSide && token() === 58) {
27137
+ ts.Debug.assert(!allowAmbiguity);
27138
+ return undefined;
27139
+ }
27136
27140
  var type = parseReturnType(58, false);
27137
27141
  if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
27138
27142
  return undefined;
@@ -27153,7 +27157,7 @@ var ts;
27153
27157
  var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
27154
27158
  return withJSDoc(finishNode(node, pos), hasJSDoc);
27155
27159
  }
27156
- function parseArrowFunctionExpressionBody(isAsync) {
27160
+ function parseArrowFunctionExpressionBody(isAsync, parsingConditionalTrueSide) {
27157
27161
  if (token() === 18) {
27158
27162
  return parseFunctionBlock(isAsync ? 2 : 0);
27159
27163
  }
@@ -27167,8 +27171,8 @@ var ts;
27167
27171
  var savedTopLevel = topLevel;
27168
27172
  topLevel = false;
27169
27173
  var node = isAsync
27170
- ? doInAwaitContext(parseAssignmentExpressionOrHigher)
27171
- : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
27174
+ ? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(parsingConditionalTrueSide); })
27175
+ : doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(parsingConditionalTrueSide); });
27172
27176
  topLevel = savedTopLevel;
27173
27177
  return node;
27174
27178
  }
@@ -27178,8 +27182,8 @@ var ts;
27178
27182
  return leftOperand;
27179
27183
  }
27180
27184
  var colonToken;
27181
- return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58), ts.nodeIsPresent(colonToken)
27182
- ? parseAssignmentExpressionOrHigher()
27185
+ return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(true); }), colonToken = parseExpectedToken(58), ts.nodeIsPresent(colonToken)
27186
+ ? parseAssignmentExpressionOrHigher(false)
27183
27187
  : createMissingNode(79, false, ts.Diagnostics._0_expected, ts.tokenToString(58))), pos);
27184
27188
  }
27185
27189
  function parseBinaryExpressionOrHigher(precedence) {
@@ -44733,12 +44737,9 @@ var ts;
44733
44737
  function isErrorType(type) {
44734
44738
  return type === errorType || !!(type.flags & 1 && type.aliasSymbol);
44735
44739
  }
44736
- function getTypeForBindingElementParent(node, checkMode) {
44737
- if (checkMode && checkMode !== 0) {
44738
- return getTypeForVariableLikeDeclaration(node, false, checkMode);
44739
- }
44740
+ function getTypeForBindingElementParent(node) {
44740
44741
  var symbol = getSymbolOfNode(node);
44741
- return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false, checkMode);
44742
+ return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false);
44742
44743
  }
44743
44744
  function getRestType(source, properties, symbol) {
44744
44745
  source = filterType(source, function (t) { return !(t.flags & 98304); });
@@ -44843,8 +44844,7 @@ var ts;
44843
44844
  return type.flags & (128 | 256) ? "" + type.value : undefined;
44844
44845
  }
44845
44846
  function getTypeForBindingElement(declaration) {
44846
- var checkMode = declaration.dotDotDotToken && declaration.parent.kind !== 201 ? 32 : 0;
44847
- var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
44847
+ var parentType = getTypeForBindingElementParent(declaration.parent.parent);
44848
44848
  return parentType && getBindingElementTypeFromParentType(declaration, parentType);
44849
44849
  }
44850
44850
  function getBindingElementTypeFromParentType(declaration, parentType) {
@@ -44904,9 +44904,9 @@ var ts;
44904
44904
  return type;
44905
44905
  }
44906
44906
  if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
44907
- return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, undefined)) & 32768) ? getNonUndefinedType(type) : type;
44907
+ return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768) ? getNonUndefinedType(type) : type;
44908
44908
  }
44909
- return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, undefined)], 2));
44909
+ return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2));
44910
44910
  }
44911
44911
  function getTypeForDeclarationFromJSDocComment(declaration) {
44912
44912
  var jsdocType = ts.getJSDocType(declaration);
@@ -44928,9 +44928,9 @@ var ts;
44928
44928
  if (isOptional === void 0) { isOptional = true; }
44929
44929
  return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type;
44930
44930
  }
44931
- function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) {
44931
+ function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
44932
44932
  if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 242) {
44933
- var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, checkMode)));
44933
+ var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression)));
44934
44934
  return indexType.flags & (262144 | 4194304) ? getExtractStringType(indexType) : stringType;
44935
44935
  }
44936
44936
  if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243) {
@@ -44992,7 +44992,7 @@ var ts;
44992
44992
  return containerObjectType;
44993
44993
  }
44994
44994
  }
44995
- var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration, checkMode));
44995
+ var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration));
44996
44996
  return addOptionality(type, isProperty, isOptional);
44997
44997
  }
44998
44998
  if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) {
@@ -45325,7 +45325,7 @@ var ts;
45325
45325
  function getTypeFromBindingElement(element, includePatternInType, reportErrors) {
45326
45326
  if (element.initializer) {
45327
45327
  var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, true, false) : unknownType;
45328
- return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, undefined, contextualType)));
45328
+ return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, contextualType)));
45329
45329
  }
45330
45330
  if (ts.isBindingPattern(element.name)) {
45331
45331
  return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
@@ -45391,7 +45391,7 @@ var ts;
45391
45391
  : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors);
45392
45392
  }
45393
45393
  function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
45394
- return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, true, undefined), declaration, reportErrors);
45394
+ return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, true), declaration, reportErrors);
45395
45395
  }
45396
45396
  function isGlobalSymbolConstructor(node) {
45397
45397
  var symbol = getSymbolOfNode(node);
@@ -56697,10 +56697,21 @@ var ts;
56697
56697
  }
56698
56698
  if (flags & 2097152) {
56699
56699
  ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068));
56700
- return ts.reduceLeft(type.types, function (facts, t) { return facts & getTypeFacts(t, ignoreObjects); }, 16777215);
56700
+ return getIntersectionTypeFacts(type, ignoreObjects);
56701
56701
  }
56702
56702
  return 16777215;
56703
56703
  }
56704
+ function getIntersectionTypeFacts(type, ignoreObjects) {
56705
+ var oredFacts = 0;
56706
+ var andedFacts = 16777215;
56707
+ for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
56708
+ var t = _a[_i];
56709
+ var f = getTypeFacts(t, ignoreObjects);
56710
+ oredFacts |= f;
56711
+ andedFacts &= f;
56712
+ }
56713
+ return oredFacts & 8288 | andedFacts & 16768927;
56714
+ }
56704
56715
  function getTypeWithFacts(type, include) {
56705
56716
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
56706
56717
  }
@@ -58299,18 +58310,16 @@ var ts;
58299
58310
  function isGenericTypeWithoutNullableConstraint(type) {
58300
58311
  return !!(type.flags & 465829888 && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304));
58301
58312
  }
58302
- function hasContextualTypeWithNoGenericTypes(node, checkMode) {
58313
+ function hasNonBindingPatternContextualTypeWithNoGenericTypes(node) {
58303
58314
  var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
58304
58315
  !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
58305
- (checkMode && checkMode & 32 ?
58306
- getContextualType(node, 8)
58307
- : getContextualType(node));
58316
+ getContextualType(node, 8);
58308
58317
  return contextualType && !isGenericType(contextualType);
58309
58318
  }
58310
58319
  function getNarrowableTypeForReference(type, reference, checkMode) {
58311
58320
  var substituteConstraints = !(checkMode && checkMode & 2) &&
58312
58321
  someType(type, isGenericTypeWithUnionConstraint) &&
58313
- (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
58322
+ (isConstraintPosition(type, reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference));
58314
58323
  return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
58315
58324
  }
58316
58325
  function isExportOrExportExpression(location) {
@@ -58352,7 +58361,7 @@ var ts;
58352
58361
  var links = getNodeLinks(location);
58353
58362
  if (!(links.flags & 268435456)) {
58354
58363
  links.flags |= 268435456;
58355
- var parentType = getTypeForBindingElementParent(parent, undefined);
58364
+ var parentType = getTypeForBindingElementParent(parent);
58356
58365
  links.flags &= ~268435456;
58357
58366
  if (parentType && parentType.flags & 1048576 && !(parent.kind === 163 && isSymbolAssigned(symbol))) {
58358
58367
  var pattern = declaration.parent;
@@ -59020,7 +59029,7 @@ var ts;
59020
59029
  var parent = declaration.parent.parent;
59021
59030
  var name = declaration.propertyName || declaration.name;
59022
59031
  var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
59023
- parent.kind !== 202 && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken && declaration.parent.kind !== 201 ? 32 : 0);
59032
+ parent.kind !== 202 && parent.initializer && checkDeclarationInitializer(parent);
59024
59033
  if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
59025
59034
  return undefined;
59026
59035
  if (parent.name.kind === 201) {
@@ -65001,11 +65010,11 @@ var ts;
65001
65010
  }
65002
65011
  }
65003
65012
  function checkExpressionCached(node, checkMode) {
65004
- if (checkMode && checkMode !== 0) {
65005
- return checkExpression(node, checkMode);
65006
- }
65007
65013
  var links = getNodeLinks(node);
65008
65014
  if (!links.resolvedType) {
65015
+ if (checkMode && checkMode !== 0) {
65016
+ return checkExpression(node, checkMode);
65017
+ }
65009
65018
  var saveFlowLoopStart = flowLoopStart;
65010
65019
  var saveFlowTypeCache = flowTypeCache;
65011
65020
  flowLoopStart = flowLoopCount;
@@ -65022,12 +65031,10 @@ var ts;
65022
65031
  node.kind === 228 ||
65023
65032
  ts.isJSDocTypeAssertion(node);
65024
65033
  }
65025
- function checkDeclarationInitializer(declaration, checkMode, contextualType) {
65034
+ function checkDeclarationInitializer(declaration, contextualType) {
65026
65035
  var initializer = ts.getEffectiveInitializer(declaration);
65027
65036
  var type = getQuickTypeOfExpression(initializer) ||
65028
- (contextualType ?
65029
- checkExpressionWithContextualType(initializer, contextualType, undefined, checkMode || 0)
65030
- : checkExpressionCached(initializer, checkMode));
65037
+ (contextualType ? checkExpressionWithContextualType(initializer, contextualType, undefined, 0) : checkExpressionCached(initializer));
65031
65038
  return ts.isParameter(declaration) && declaration.name.kind === 201 &&
65032
65039
  isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
65033
65040
  padTupleType(type, declaration.name) : type;
@@ -67501,8 +67508,7 @@ var ts;
67501
67508
  checkComputedPropertyName(node.propertyName);
67502
67509
  }
67503
67510
  var parent = node.parent.parent;
67504
- var parentCheckMode = node.dotDotDotToken && node.parent.kind !== 201 ? 32 : 0;
67505
- var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
67511
+ var parentType = getTypeForBindingElementParent(parent);
67506
67512
  var name = node.propertyName || node.name;
67507
67513
  if (parentType && !ts.isBindingPattern(name)) {
67508
67514
  var exprType = getLiteralTypeFromPropertyName(name);
@@ -68466,7 +68472,7 @@ var ts;
68466
68472
  var declaration = catchClause.variableDeclaration;
68467
68473
  var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration));
68468
68474
  if (typeNode) {
68469
- var type = getTypeForVariableLikeDeclaration(declaration, false, undefined);
68475
+ var type = getTypeForVariableLikeDeclaration(declaration, false);
68470
68476
  if (type && !(type.flags & 3)) {
68471
68477
  grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified);
68472
68478
  }
@@ -70885,7 +70891,7 @@ var ts;
70885
70891
  return errorType;
70886
70892
  }
70887
70893
  if (ts.isBindingPattern(node)) {
70888
- return getTypeForVariableLikeDeclaration(node.parent, true, undefined) || errorType;
70894
+ return getTypeForVariableLikeDeclaration(node.parent, true) || errorType;
70889
70895
  }
70890
70896
  if (isInRightSideOfImportOrExportAssignment(node)) {
70891
70897
  var symbol = getSymbolAtLocation(node);