@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/tsc.js CHANGED
@@ -69,15 +69,21 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.6";
72
- ts.version = ts.versionMajorMinor + ".0-insiders.20220121";
72
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220124";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
+ var globals = typeof globalThis !== "undefined" ? globalThis :
76
+ typeof global !== "undefined" ? global :
77
+ typeof self !== "undefined" ? self :
78
+ undefined;
75
79
  function tryGetNativeMap() {
76
- return typeof Map !== "undefined" && "entries" in Map.prototype && new Map([[0, 0]]).size === 1 ? Map : undefined;
80
+ var gMap = globals === null || globals === void 0 ? void 0 : globals.Map;
81
+ return typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
77
82
  }
78
83
  NativeCollections.tryGetNativeMap = tryGetNativeMap;
79
84
  function tryGetNativeSet() {
80
- return typeof Set !== "undefined" && "entries" in Set.prototype && new Set([0]).size === 1 ? Set : undefined;
85
+ var gSet = globals === null || globals === void 0 ? void 0 : globals.Set;
86
+ return typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
81
87
  }
82
88
  NativeCollections.tryGetNativeSet = tryGetNativeSet;
83
89
  })(NativeCollections || (NativeCollections = {}));
@@ -26926,18 +26932,18 @@ var ts;
26926
26932
  function parseInitializer() {
26927
26933
  return parseOptional(63) ? parseAssignmentExpressionOrHigher() : undefined;
26928
26934
  }
26929
- function parseAssignmentExpressionOrHigher() {
26935
+ function parseAssignmentExpressionOrHigher(parsingConditionalExpression) {
26930
26936
  if (isYieldExpression()) {
26931
26937
  return parseYieldExpression();
26932
26938
  }
26933
- var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
26939
+ var arrowExpression = tryParseParenthesizedArrowFunctionExpression(parsingConditionalExpression) || tryParseAsyncSimpleArrowFunctionExpression();
26934
26940
  if (arrowExpression) {
26935
26941
  return arrowExpression;
26936
26942
  }
26937
26943
  var pos = getNodePos();
26938
26944
  var expr = parseBinaryExpressionOrHigher(0);
26939
26945
  if (expr.kind === 79 && token() === 38) {
26940
- return parseSimpleArrowFunctionExpression(pos, expr, undefined);
26946
+ return parseSimpleArrowFunctionExpression(pos, expr, undefined, parsingConditionalExpression);
26941
26947
  }
26942
26948
  if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) {
26943
26949
  return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos);
@@ -26968,24 +26974,24 @@ var ts;
26968
26974
  return finishNode(factory.createYieldExpression(undefined, undefined), pos);
26969
26975
  }
26970
26976
  }
26971
- function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) {
26977
+ function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier, parsingConditionalExpression) {
26972
26978
  ts.Debug.assert(token() === 38, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
26973
26979
  var parameter = factory.createParameterDeclaration(undefined, undefined, undefined, identifier, undefined, undefined, undefined);
26974
26980
  finishNode(parameter, identifier.pos);
26975
26981
  var parameters = createNodeArray([parameter], parameter.pos, parameter.end);
26976
26982
  var equalsGreaterThanToken = parseExpectedToken(38);
26977
- var body = parseArrowFunctionExpressionBody(!!asyncModifier);
26983
+ var body = parseArrowFunctionExpressionBody(!!asyncModifier, parsingConditionalExpression);
26978
26984
  var node = factory.createArrowFunction(asyncModifier, undefined, parameters, undefined, equalsGreaterThanToken, body);
26979
26985
  return addJSDocComment(finishNode(node, pos));
26980
26986
  }
26981
- function tryParseParenthesizedArrowFunctionExpression() {
26987
+ function tryParseParenthesizedArrowFunctionExpression(parsingConditionalExpression) {
26982
26988
  var triState = isParenthesizedArrowFunctionExpression();
26983
26989
  if (triState === 0) {
26984
26990
  return undefined;
26985
26991
  }
26986
26992
  return triState === 1 ?
26987
- parseParenthesizedArrowFunctionExpression(true) :
26988
- tryParse(parsePossibleParenthesizedArrowFunctionExpression);
26993
+ parseParenthesizedArrowFunctionExpression(true, parsingConditionalExpression) :
26994
+ tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(parsingConditionalExpression); });
26989
26995
  }
26990
26996
  function isParenthesizedArrowFunctionExpression() {
26991
26997
  if (token() === 20 || token() === 29 || token() === 131) {
@@ -27079,24 +27085,24 @@ var ts;
27079
27085
  return 2;
27080
27086
  }
27081
27087
  }
27082
- function parsePossibleParenthesizedArrowFunctionExpression() {
27088
+ function parsePossibleParenthesizedArrowFunctionExpression(parsingConditionalExpression) {
27083
27089
  var tokenPos = scanner.getTokenPos();
27084
27090
  if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) {
27085
27091
  return undefined;
27086
27092
  }
27087
- var result = parseParenthesizedArrowFunctionExpression(false);
27093
+ var result = parseParenthesizedArrowFunctionExpression(false, parsingConditionalExpression);
27088
27094
  if (!result) {
27089
27095
  (notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos);
27090
27096
  }
27091
27097
  return result;
27092
27098
  }
27093
- function tryParseAsyncSimpleArrowFunctionExpression() {
27099
+ function tryParseAsyncSimpleArrowFunctionExpression(parsingConditionalExpression) {
27094
27100
  if (token() === 131) {
27095
27101
  if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1) {
27096
27102
  var pos = getNodePos();
27097
27103
  var asyncModifier = parseModifiersForArrowFunction();
27098
27104
  var expr = parseBinaryExpressionOrHigher(0);
27099
- return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier);
27105
+ return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier, parsingConditionalExpression);
27100
27106
  }
27101
27107
  }
27102
27108
  return undefined;
@@ -27114,7 +27120,7 @@ var ts;
27114
27120
  }
27115
27121
  return 0;
27116
27122
  }
27117
- function parseParenthesizedArrowFunctionExpression(allowAmbiguity) {
27123
+ function parseParenthesizedArrowFunctionExpression(allowAmbiguity, parsingConditionalExpression) {
27118
27124
  var pos = getNodePos();
27119
27125
  var hasJSDoc = hasPrecedingJSDocComment();
27120
27126
  var modifiers = parseModifiersForArrowFunction();
@@ -27133,6 +27139,10 @@ var ts;
27133
27139
  return undefined;
27134
27140
  }
27135
27141
  }
27142
+ if (parsingConditionalExpression && token() === 58) {
27143
+ ts.Debug.assert(!allowAmbiguity);
27144
+ return undefined;
27145
+ }
27136
27146
  var type = parseReturnType(58, false);
27137
27147
  if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
27138
27148
  return undefined;
@@ -27153,7 +27163,7 @@ var ts;
27153
27163
  var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
27154
27164
  return withJSDoc(finishNode(node, pos), hasJSDoc);
27155
27165
  }
27156
- function parseArrowFunctionExpressionBody(isAsync) {
27166
+ function parseArrowFunctionExpressionBody(isAsync, parsingConditionalExpression) {
27157
27167
  if (token() === 18) {
27158
27168
  return parseFunctionBlock(isAsync ? 2 : 0);
27159
27169
  }
@@ -27167,8 +27177,8 @@ var ts;
27167
27177
  var savedTopLevel = topLevel;
27168
27178
  topLevel = false;
27169
27179
  var node = isAsync
27170
- ? doInAwaitContext(parseAssignmentExpressionOrHigher)
27171
- : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
27180
+ ? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(parsingConditionalExpression); })
27181
+ : doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(parsingConditionalExpression); });
27172
27182
  topLevel = savedTopLevel;
27173
27183
  return node;
27174
27184
  }
@@ -27178,8 +27188,8 @@ var ts;
27178
27188
  return leftOperand;
27179
27189
  }
27180
27190
  var colonToken;
27181
- return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58), ts.nodeIsPresent(colonToken)
27182
- ? parseAssignmentExpressionOrHigher()
27191
+ return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(true); }), colonToken = parseExpectedToken(58), ts.nodeIsPresent(colonToken)
27192
+ ? parseAssignmentExpressionOrHigher(true)
27183
27193
  : createMissingNode(79, false, ts.Diagnostics._0_expected, ts.tokenToString(58))), pos);
27184
27194
  }
27185
27195
  function parseBinaryExpressionOrHigher(precedence) {
@@ -44733,12 +44743,9 @@ var ts;
44733
44743
  function isErrorType(type) {
44734
44744
  return type === errorType || !!(type.flags & 1 && type.aliasSymbol);
44735
44745
  }
44736
- function getTypeForBindingElementParent(node, checkMode) {
44737
- if (checkMode && checkMode !== 0) {
44738
- return getTypeForVariableLikeDeclaration(node, false, checkMode);
44739
- }
44746
+ function getTypeForBindingElementParent(node) {
44740
44747
  var symbol = getSymbolOfNode(node);
44741
- return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false, checkMode);
44748
+ return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false);
44742
44749
  }
44743
44750
  function getRestType(source, properties, symbol) {
44744
44751
  source = filterType(source, function (t) { return !(t.flags & 98304); });
@@ -44843,8 +44850,7 @@ var ts;
44843
44850
  return type.flags & (128 | 256) ? "" + type.value : undefined;
44844
44851
  }
44845
44852
  function getTypeForBindingElement(declaration) {
44846
- var checkMode = declaration.dotDotDotToken && declaration.parent.kind !== 201 ? 32 : 0;
44847
- var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
44853
+ var parentType = getTypeForBindingElementParent(declaration.parent.parent);
44848
44854
  return parentType && getBindingElementTypeFromParentType(declaration, parentType);
44849
44855
  }
44850
44856
  function getBindingElementTypeFromParentType(declaration, parentType) {
@@ -44904,9 +44910,9 @@ var ts;
44904
44910
  return type;
44905
44911
  }
44906
44912
  if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
44907
- return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, undefined)) & 32768) ? getNonUndefinedType(type) : type;
44913
+ return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768) ? getNonUndefinedType(type) : type;
44908
44914
  }
44909
- return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, undefined)], 2));
44915
+ return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2));
44910
44916
  }
44911
44917
  function getTypeForDeclarationFromJSDocComment(declaration) {
44912
44918
  var jsdocType = ts.getJSDocType(declaration);
@@ -44928,9 +44934,9 @@ var ts;
44928
44934
  if (isOptional === void 0) { isOptional = true; }
44929
44935
  return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type;
44930
44936
  }
44931
- function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) {
44937
+ function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
44932
44938
  if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 242) {
44933
- var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, checkMode)));
44939
+ var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression)));
44934
44940
  return indexType.flags & (262144 | 4194304) ? getExtractStringType(indexType) : stringType;
44935
44941
  }
44936
44942
  if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243) {
@@ -44992,7 +44998,7 @@ var ts;
44992
44998
  return containerObjectType;
44993
44999
  }
44994
45000
  }
44995
- var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration, checkMode));
45001
+ var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration));
44996
45002
  return addOptionality(type, isProperty, isOptional);
44997
45003
  }
44998
45004
  if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) {
@@ -45325,7 +45331,7 @@ var ts;
45325
45331
  function getTypeFromBindingElement(element, includePatternInType, reportErrors) {
45326
45332
  if (element.initializer) {
45327
45333
  var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, true, false) : unknownType;
45328
- return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, undefined, contextualType)));
45334
+ return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, contextualType)));
45329
45335
  }
45330
45336
  if (ts.isBindingPattern(element.name)) {
45331
45337
  return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
@@ -45391,7 +45397,7 @@ var ts;
45391
45397
  : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors);
45392
45398
  }
45393
45399
  function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
45394
- return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, true, undefined), declaration, reportErrors);
45400
+ return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, true), declaration, reportErrors);
45395
45401
  }
45396
45402
  function isGlobalSymbolConstructor(node) {
45397
45403
  var symbol = getSymbolOfNode(node);
@@ -56697,10 +56703,21 @@ var ts;
56697
56703
  }
56698
56704
  if (flags & 2097152) {
56699
56705
  ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068));
56700
- return ts.reduceLeft(type.types, function (facts, t) { return facts & getTypeFacts(t, ignoreObjects); }, 16777215);
56706
+ return getIntersectionTypeFacts(type, ignoreObjects);
56701
56707
  }
56702
56708
  return 16777215;
56703
56709
  }
56710
+ function getIntersectionTypeFacts(type, ignoreObjects) {
56711
+ var oredFacts = 0;
56712
+ var andedFacts = 16777215;
56713
+ for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
56714
+ var t = _a[_i];
56715
+ var f = getTypeFacts(t, ignoreObjects);
56716
+ oredFacts |= f;
56717
+ andedFacts &= f;
56718
+ }
56719
+ return oredFacts & 8288 | andedFacts & 16768927;
56720
+ }
56704
56721
  function getTypeWithFacts(type, include) {
56705
56722
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
56706
56723
  }
@@ -58299,18 +58316,16 @@ var ts;
58299
58316
  function isGenericTypeWithoutNullableConstraint(type) {
58300
58317
  return !!(type.flags & 465829888 && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304));
58301
58318
  }
58302
- function hasContextualTypeWithNoGenericTypes(node, checkMode) {
58319
+ function hasNonBindingPatternContextualTypeWithNoGenericTypes(node) {
58303
58320
  var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
58304
58321
  !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
58305
- (checkMode && checkMode & 32 ?
58306
- getContextualType(node, 8)
58307
- : getContextualType(node));
58322
+ getContextualType(node, 8);
58308
58323
  return contextualType && !isGenericType(contextualType);
58309
58324
  }
58310
58325
  function getNarrowableTypeForReference(type, reference, checkMode) {
58311
58326
  var substituteConstraints = !(checkMode && checkMode & 2) &&
58312
58327
  someType(type, isGenericTypeWithUnionConstraint) &&
58313
- (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
58328
+ (isConstraintPosition(type, reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference));
58314
58329
  return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
58315
58330
  }
58316
58331
  function isExportOrExportExpression(location) {
@@ -58352,7 +58367,7 @@ var ts;
58352
58367
  var links = getNodeLinks(location);
58353
58368
  if (!(links.flags & 268435456)) {
58354
58369
  links.flags |= 268435456;
58355
- var parentType = getTypeForBindingElementParent(parent, undefined);
58370
+ var parentType = getTypeForBindingElementParent(parent);
58356
58371
  links.flags &= ~268435456;
58357
58372
  if (parentType && parentType.flags & 1048576 && !(parent.kind === 163 && isSymbolAssigned(symbol))) {
58358
58373
  var pattern = declaration.parent;
@@ -59020,7 +59035,7 @@ var ts;
59020
59035
  var parent = declaration.parent.parent;
59021
59036
  var name = declaration.propertyName || declaration.name;
59022
59037
  var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
59023
- parent.kind !== 202 && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken && declaration.parent.kind !== 201 ? 32 : 0);
59038
+ parent.kind !== 202 && parent.initializer && checkDeclarationInitializer(parent);
59024
59039
  if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
59025
59040
  return undefined;
59026
59041
  if (parent.name.kind === 201) {
@@ -65001,11 +65016,11 @@ var ts;
65001
65016
  }
65002
65017
  }
65003
65018
  function checkExpressionCached(node, checkMode) {
65004
- if (checkMode && checkMode !== 0) {
65005
- return checkExpression(node, checkMode);
65006
- }
65007
65019
  var links = getNodeLinks(node);
65008
65020
  if (!links.resolvedType) {
65021
+ if (checkMode && checkMode !== 0) {
65022
+ return checkExpression(node, checkMode);
65023
+ }
65009
65024
  var saveFlowLoopStart = flowLoopStart;
65010
65025
  var saveFlowTypeCache = flowTypeCache;
65011
65026
  flowLoopStart = flowLoopCount;
@@ -65022,12 +65037,10 @@ var ts;
65022
65037
  node.kind === 228 ||
65023
65038
  ts.isJSDocTypeAssertion(node);
65024
65039
  }
65025
- function checkDeclarationInitializer(declaration, checkMode, contextualType) {
65040
+ function checkDeclarationInitializer(declaration, contextualType) {
65026
65041
  var initializer = ts.getEffectiveInitializer(declaration);
65027
65042
  var type = getQuickTypeOfExpression(initializer) ||
65028
- (contextualType ?
65029
- checkExpressionWithContextualType(initializer, contextualType, undefined, checkMode || 0)
65030
- : checkExpressionCached(initializer, checkMode));
65043
+ (contextualType ? checkExpressionWithContextualType(initializer, contextualType, undefined, 0) : checkExpressionCached(initializer));
65031
65044
  return ts.isParameter(declaration) && declaration.name.kind === 201 &&
65032
65045
  isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
65033
65046
  padTupleType(type, declaration.name) : type;
@@ -67501,8 +67514,7 @@ var ts;
67501
67514
  checkComputedPropertyName(node.propertyName);
67502
67515
  }
67503
67516
  var parent = node.parent.parent;
67504
- var parentCheckMode = node.dotDotDotToken && node.parent.kind !== 201 ? 32 : 0;
67505
- var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
67517
+ var parentType = getTypeForBindingElementParent(parent);
67506
67518
  var name = node.propertyName || node.name;
67507
67519
  if (parentType && !ts.isBindingPattern(name)) {
67508
67520
  var exprType = getLiteralTypeFromPropertyName(name);
@@ -68466,7 +68478,7 @@ var ts;
68466
68478
  var declaration = catchClause.variableDeclaration;
68467
68479
  var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration));
68468
68480
  if (typeNode) {
68469
- var type = getTypeForVariableLikeDeclaration(declaration, false, undefined);
68481
+ var type = getTypeForVariableLikeDeclaration(declaration, false);
68470
68482
  if (type && !(type.flags & 3)) {
68471
68483
  grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified);
68472
68484
  }
@@ -70885,7 +70897,7 @@ var ts;
70885
70897
  return errorType;
70886
70898
  }
70887
70899
  if (ts.isBindingPattern(node)) {
70888
- return getTypeForVariableLikeDeclaration(node.parent, true, undefined) || errorType;
70900
+ return getTypeForVariableLikeDeclaration(node.parent, true) || errorType;
70889
70901
  }
70890
70902
  if (isInRightSideOfImportOrExportAssignment(node)) {
70891
70903
  var symbol = getSymbolAtLocation(node);