@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 +57 -51
- package/lib/tsserver.js +71 -59
- package/lib/tsserverlibrary.js +71 -59
- package/lib/typescript.js +71 -59
- package/lib/typescriptServices.js +71 -59
- package/lib/typingsInstaller.js +71 -59
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -33366,7 +33366,7 @@ var ts;
|
|
|
33366
33366
|
function parseInitializer() {
|
|
33367
33367
|
return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined;
|
|
33368
33368
|
}
|
|
33369
|
-
function parseAssignmentExpressionOrHigher() {
|
|
33369
|
+
function parseAssignmentExpressionOrHigher(parsingConditionalTrueSide) {
|
|
33370
33370
|
// AssignmentExpression[in,yield]:
|
|
33371
33371
|
// 1) ConditionalExpression[?in,?yield]
|
|
33372
33372
|
// 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
|
|
@@ -33392,7 +33392,7 @@ var ts;
|
|
|
33392
33392
|
// If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
|
|
33393
33393
|
// not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
|
|
33394
33394
|
// with AssignmentExpression if we see one.
|
|
33395
|
-
var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
|
|
33395
|
+
var arrowExpression = tryParseParenthesizedArrowFunctionExpression(parsingConditionalTrueSide) || tryParseAsyncSimpleArrowFunctionExpression();
|
|
33396
33396
|
if (arrowExpression) {
|
|
33397
33397
|
return arrowExpression;
|
|
33398
33398
|
}
|
|
@@ -33411,7 +33411,7 @@ var ts;
|
|
|
33411
33411
|
// parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single
|
|
33412
33412
|
// identifier and the current token is an arrow.
|
|
33413
33413
|
if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) {
|
|
33414
|
-
return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined);
|
|
33414
|
+
return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined, parsingConditionalTrueSide);
|
|
33415
33415
|
}
|
|
33416
33416
|
// Now see if we might be in cases '2' or '3'.
|
|
33417
33417
|
// If the expression was a LHS expression, and we have an assignment operator, then
|
|
@@ -33471,7 +33471,7 @@ var ts;
|
|
|
33471
33471
|
return finishNode(factory.createYieldExpression(/*asteriskToken*/ undefined, /*expression*/ undefined), pos);
|
|
33472
33472
|
}
|
|
33473
33473
|
}
|
|
33474
|
-
function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) {
|
|
33474
|
+
function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier, parsingConditionalTrueSide) {
|
|
33475
33475
|
ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
|
|
33476
33476
|
var parameter = factory.createParameterDeclaration(
|
|
33477
33477
|
/*decorators*/ undefined,
|
|
@@ -33483,11 +33483,11 @@ var ts;
|
|
|
33483
33483
|
finishNode(parameter, identifier.pos);
|
|
33484
33484
|
var parameters = createNodeArray([parameter], parameter.pos, parameter.end);
|
|
33485
33485
|
var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
|
|
33486
|
-
var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier);
|
|
33486
|
+
var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, parsingConditionalTrueSide);
|
|
33487
33487
|
var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body);
|
|
33488
33488
|
return addJSDocComment(finishNode(node, pos));
|
|
33489
33489
|
}
|
|
33490
|
-
function tryParseParenthesizedArrowFunctionExpression() {
|
|
33490
|
+
function tryParseParenthesizedArrowFunctionExpression(parsingConditionalTrueSide) {
|
|
33491
33491
|
var triState = isParenthesizedArrowFunctionExpression();
|
|
33492
33492
|
if (triState === 0 /* False */) {
|
|
33493
33493
|
// It's definitely not a parenthesized arrow function expression.
|
|
@@ -33498,8 +33498,8 @@ var ts;
|
|
|
33498
33498
|
// it out, but don't allow any ambiguity, and return 'undefined' if this could be an
|
|
33499
33499
|
// expression instead.
|
|
33500
33500
|
return triState === 1 /* True */ ?
|
|
33501
|
-
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) :
|
|
33502
|
-
tryParse(parsePossibleParenthesizedArrowFunctionExpression);
|
|
33501
|
+
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, parsingConditionalTrueSide) :
|
|
33502
|
+
tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(parsingConditionalTrueSide); });
|
|
33503
33503
|
}
|
|
33504
33504
|
// True -> We definitely expect a parenthesized arrow function here.
|
|
33505
33505
|
// False -> There *cannot* be a parenthesized arrow function here.
|
|
@@ -33629,25 +33629,25 @@ var ts;
|
|
|
33629
33629
|
return 2 /* Unknown */;
|
|
33630
33630
|
}
|
|
33631
33631
|
}
|
|
33632
|
-
function parsePossibleParenthesizedArrowFunctionExpression() {
|
|
33632
|
+
function parsePossibleParenthesizedArrowFunctionExpression(parsingConditionalTrueSide) {
|
|
33633
33633
|
var tokenPos = scanner.getTokenPos();
|
|
33634
33634
|
if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) {
|
|
33635
33635
|
return undefined;
|
|
33636
33636
|
}
|
|
33637
|
-
var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false);
|
|
33637
|
+
var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false, parsingConditionalTrueSide);
|
|
33638
33638
|
if (!result) {
|
|
33639
33639
|
(notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos);
|
|
33640
33640
|
}
|
|
33641
33641
|
return result;
|
|
33642
33642
|
}
|
|
33643
|
-
function tryParseAsyncSimpleArrowFunctionExpression() {
|
|
33643
|
+
function tryParseAsyncSimpleArrowFunctionExpression(parsingConditionalTrueSide) {
|
|
33644
33644
|
// We do a check here so that we won't be doing unnecessarily call to "lookAhead"
|
|
33645
33645
|
if (token() === 131 /* AsyncKeyword */) {
|
|
33646
33646
|
if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) {
|
|
33647
33647
|
var pos = getNodePos();
|
|
33648
33648
|
var asyncModifier = parseModifiersForArrowFunction();
|
|
33649
33649
|
var expr = parseBinaryExpressionOrHigher(0 /* Lowest */);
|
|
33650
|
-
return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier);
|
|
33650
|
+
return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier, parsingConditionalTrueSide);
|
|
33651
33651
|
}
|
|
33652
33652
|
}
|
|
33653
33653
|
return undefined;
|
|
@@ -33671,7 +33671,7 @@ var ts;
|
|
|
33671
33671
|
}
|
|
33672
33672
|
return 0 /* False */;
|
|
33673
33673
|
}
|
|
33674
|
-
function parseParenthesizedArrowFunctionExpression(allowAmbiguity) {
|
|
33674
|
+
function parseParenthesizedArrowFunctionExpression(allowAmbiguity, parsingConditionalTrueSide) {
|
|
33675
33675
|
var pos = getNodePos();
|
|
33676
33676
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
33677
33677
|
var modifiers = parseModifiersForArrowFunction();
|
|
@@ -33697,6 +33697,18 @@ var ts;
|
|
|
33697
33697
|
return undefined;
|
|
33698
33698
|
}
|
|
33699
33699
|
}
|
|
33700
|
+
// Given:
|
|
33701
|
+
// x ? y => ({ y }) : z => ({ z })
|
|
33702
|
+
// We try to parse the body of the first arrow function by looking at:
|
|
33703
|
+
// ({ y }) : z => ({ z })
|
|
33704
|
+
// This is a valid arrow function with "z" as the return type.
|
|
33705
|
+
//
|
|
33706
|
+
// But, if we're in the true side of a conditional expression, this colon
|
|
33707
|
+
// terminates the true side, so cannot be the return type.
|
|
33708
|
+
if (parsingConditionalTrueSide && token() === 58 /* ColonToken */) {
|
|
33709
|
+
ts.Debug.assert(!allowAmbiguity);
|
|
33710
|
+
return undefined;
|
|
33711
|
+
}
|
|
33700
33712
|
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
|
33701
33713
|
if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
|
|
33702
33714
|
return undefined;
|
|
@@ -33730,7 +33742,7 @@ var ts;
|
|
|
33730
33742
|
var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
|
|
33731
33743
|
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
|
33732
33744
|
}
|
|
33733
|
-
function parseArrowFunctionExpressionBody(isAsync) {
|
|
33745
|
+
function parseArrowFunctionExpressionBody(isAsync, parsingConditionalTrueSide) {
|
|
33734
33746
|
if (token() === 18 /* OpenBraceToken */) {
|
|
33735
33747
|
return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */);
|
|
33736
33748
|
}
|
|
@@ -33758,8 +33770,8 @@ var ts;
|
|
|
33758
33770
|
var savedTopLevel = topLevel;
|
|
33759
33771
|
topLevel = false;
|
|
33760
33772
|
var node = isAsync
|
|
33761
|
-
? doInAwaitContext(parseAssignmentExpressionOrHigher)
|
|
33762
|
-
: doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
|
|
33773
|
+
? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(parsingConditionalTrueSide); })
|
|
33774
|
+
: doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(parsingConditionalTrueSide); });
|
|
33763
33775
|
topLevel = savedTopLevel;
|
|
33764
33776
|
return node;
|
|
33765
33777
|
}
|
|
@@ -33772,8 +33784,8 @@ var ts;
|
|
|
33772
33784
|
// Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and
|
|
33773
33785
|
// we do not that for the 'whenFalse' part.
|
|
33774
33786
|
var colonToken;
|
|
33775
|
-
return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
|
|
33776
|
-
? parseAssignmentExpressionOrHigher()
|
|
33787
|
+
return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*parsingConditionalTrueSide*/ true); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
|
|
33788
|
+
? parseAssignmentExpressionOrHigher(/*parsingConditionalTrueSide*/ false)
|
|
33777
33789
|
: createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos);
|
|
33778
33790
|
}
|
|
33779
33791
|
function parseBinaryExpressionOrHigher(precedence) {
|
|
@@ -46788,6 +46800,9 @@ var ts;
|
|
|
46788
46800
|
TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts";
|
|
46789
46801
|
TypeFacts[TypeFacts["AllTypeofNE"] = 556800] = "AllTypeofNE";
|
|
46790
46802
|
TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts";
|
|
46803
|
+
// Masks
|
|
46804
|
+
TypeFacts[TypeFacts["OrFactsMask"] = 8288] = "OrFactsMask";
|
|
46805
|
+
TypeFacts[TypeFacts["AndFactsMask"] = 16768927] = "AndFactsMask";
|
|
46791
46806
|
})(TypeFacts || (TypeFacts = {}));
|
|
46792
46807
|
var typeofEQFacts = new ts.Map(ts.getEntries({
|
|
46793
46808
|
string: 1 /* TypeofEQString */,
|
|
@@ -46828,10 +46843,6 @@ var ts;
|
|
|
46828
46843
|
CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
46829
46844
|
CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
46830
46845
|
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
46846
|
})(CheckMode || (CheckMode = {}));
|
|
46836
46847
|
var SignatureCheckMode;
|
|
46837
46848
|
(function (SignatureCheckMode) {
|
|
@@ -54256,12 +54267,9 @@ var ts;
|
|
|
54256
54267
|
}
|
|
54257
54268
|
// Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
|
|
54258
54269
|
// assigned by contextual typing.
|
|
54259
|
-
function getTypeForBindingElementParent(node
|
|
54260
|
-
if (checkMode && checkMode !== 0 /* Normal */) {
|
|
54261
|
-
return getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode);
|
|
54262
|
-
}
|
|
54270
|
+
function getTypeForBindingElementParent(node) {
|
|
54263
54271
|
var symbol = getSymbolOfNode(node);
|
|
54264
|
-
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false
|
|
54272
|
+
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false);
|
|
54265
54273
|
}
|
|
54266
54274
|
function getRestType(source, properties, symbol) {
|
|
54267
54275
|
source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); });
|
|
@@ -54379,8 +54387,7 @@ var ts;
|
|
|
54379
54387
|
}
|
|
54380
54388
|
/** Return the inferred type for a binding element */
|
|
54381
54389
|
function getTypeForBindingElement(declaration) {
|
|
54382
|
-
var
|
|
54383
|
-
var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
54390
|
+
var parentType = getTypeForBindingElementParent(declaration.parent.parent);
|
|
54384
54391
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
54385
54392
|
}
|
|
54386
54393
|
function getBindingElementTypeFromParentType(declaration, parentType) {
|
|
@@ -54452,9 +54459,9 @@ var ts;
|
|
|
54452
54459
|
if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
|
|
54453
54460
|
// In strict null checking mode, if a default value of a non-undefined type is specified, remove
|
|
54454
54461
|
// undefined from the final type.
|
|
54455
|
-
return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration
|
|
54462
|
+
return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
|
|
54456
54463
|
}
|
|
54457
|
-
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration
|
|
54464
|
+
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2 /* Subtype */));
|
|
54458
54465
|
}
|
|
54459
54466
|
function getTypeForDeclarationFromJSDocComment(declaration) {
|
|
54460
54467
|
var jsdocType = ts.getJSDocType(declaration);
|
|
@@ -54477,12 +54484,11 @@ var ts;
|
|
|
54477
54484
|
return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type;
|
|
54478
54485
|
}
|
|
54479
54486
|
// Return the inferred type for a variable, parameter, or property declaration
|
|
54480
|
-
function getTypeForVariableLikeDeclaration(declaration, includeOptionality
|
|
54481
|
-
checkMode) {
|
|
54487
|
+
function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
|
|
54482
54488
|
// A variable declared in a for..in statement is of type string, or of type keyof T when the
|
|
54483
54489
|
// right hand expression is of a type parameter type.
|
|
54484
54490
|
if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 242 /* ForInStatement */) {
|
|
54485
|
-
var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression
|
|
54491
|
+
var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression)));
|
|
54486
54492
|
return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType;
|
|
54487
54493
|
}
|
|
54488
54494
|
if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForOfStatement */) {
|
|
@@ -54559,7 +54565,7 @@ var ts;
|
|
|
54559
54565
|
return containerObjectType;
|
|
54560
54566
|
}
|
|
54561
54567
|
}
|
|
54562
|
-
var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration
|
|
54568
|
+
var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration));
|
|
54563
54569
|
return addOptionality(type, isProperty, isOptional);
|
|
54564
54570
|
}
|
|
54565
54571
|
if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) {
|
|
@@ -54931,7 +54937,7 @@ var ts;
|
|
|
54931
54937
|
// contextual type or, if the element itself is a binding pattern, with the type implied by that binding
|
|
54932
54938
|
// pattern.
|
|
54933
54939
|
var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType;
|
|
54934
|
-
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element,
|
|
54940
|
+
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, contextualType)));
|
|
54935
54941
|
}
|
|
54936
54942
|
if (ts.isBindingPattern(element.name)) {
|
|
54937
54943
|
return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
|
|
@@ -55020,7 +55026,7 @@ var ts;
|
|
|
55020
55026
|
// binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the
|
|
55021
55027
|
// tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string.
|
|
55022
55028
|
function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
|
|
55023
|
-
return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true
|
|
55029
|
+
return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true), declaration, reportErrors);
|
|
55024
55030
|
}
|
|
55025
55031
|
function isGlobalSymbolConstructor(node) {
|
|
55026
55032
|
var symbol = getSymbolOfNode(node);
|
|
@@ -67938,10 +67944,23 @@ var ts;
|
|
|
67938
67944
|
// When an intersection contains a primitive type we ignore object type constituents as they are
|
|
67939
67945
|
// presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type.
|
|
67940
67946
|
ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */));
|
|
67941
|
-
return
|
|
67947
|
+
return getIntersectionTypeFacts(type, ignoreObjects);
|
|
67942
67948
|
}
|
|
67943
67949
|
return 16777215 /* All */;
|
|
67944
67950
|
}
|
|
67951
|
+
function getIntersectionTypeFacts(type, ignoreObjects) {
|
|
67952
|
+
// When computing the type facts of an intersection type, certain type facts are computed as `and`
|
|
67953
|
+
// and others are computed as `or`.
|
|
67954
|
+
var oredFacts = 0 /* None */;
|
|
67955
|
+
var andedFacts = 16777215 /* All */;
|
|
67956
|
+
for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
|
|
67957
|
+
var t = _a[_i];
|
|
67958
|
+
var f = getTypeFacts(t, ignoreObjects);
|
|
67959
|
+
oredFacts |= f;
|
|
67960
|
+
andedFacts &= f;
|
|
67961
|
+
}
|
|
67962
|
+
return oredFacts & 8288 /* OrFactsMask */ | andedFacts & 16768927 /* AndFactsMask */;
|
|
67963
|
+
}
|
|
67945
67964
|
function getTypeWithFacts(type, include) {
|
|
67946
67965
|
return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
|
|
67947
67966
|
}
|
|
@@ -69766,16 +69785,12 @@ var ts;
|
|
|
69766
69785
|
function isGenericTypeWithoutNullableConstraint(type) {
|
|
69767
69786
|
return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
69768
69787
|
}
|
|
69769
|
-
function
|
|
69788
|
+
function hasNonBindingPatternContextualTypeWithNoGenericTypes(node) {
|
|
69770
69789
|
// Computing the contextual type for a child of a JSX element involves resolving the type of the
|
|
69771
69790
|
// 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
69791
|
var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
|
|
69775
69792
|
!((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
|
|
69776
|
-
(
|
|
69777
|
-
getContextualType(node, 8 /* SkipBindingPatterns */)
|
|
69778
|
-
: getContextualType(node));
|
|
69793
|
+
getContextualType(node, 8 /* SkipBindingPatterns */);
|
|
69779
69794
|
return contextualType && !isGenericType(contextualType);
|
|
69780
69795
|
}
|
|
69781
69796
|
function getNarrowableTypeForReference(type, reference, checkMode) {
|
|
@@ -69788,7 +69803,7 @@ var ts;
|
|
|
69788
69803
|
// 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'.
|
|
69789
69804
|
var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
|
|
69790
69805
|
someType(type, isGenericTypeWithUnionConstraint) &&
|
|
69791
|
-
(isConstraintPosition(type, reference) ||
|
|
69806
|
+
(isConstraintPosition(type, reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference));
|
|
69792
69807
|
return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
|
|
69793
69808
|
}
|
|
69794
69809
|
function isExportOrExportExpression(location) {
|
|
@@ -69856,7 +69871,7 @@ var ts;
|
|
|
69856
69871
|
var links = getNodeLinks(location);
|
|
69857
69872
|
if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
|
|
69858
69873
|
links.flags |= 268435456 /* InCheckIdentifier */;
|
|
69859
|
-
var parentType = getTypeForBindingElementParent(parent
|
|
69874
|
+
var parentType = getTypeForBindingElementParent(parent);
|
|
69860
69875
|
links.flags &= ~268435456 /* InCheckIdentifier */;
|
|
69861
69876
|
if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
|
|
69862
69877
|
var pattern = declaration.parent;
|
|
@@ -70706,7 +70721,7 @@ var ts;
|
|
|
70706
70721
|
var parent = declaration.parent.parent;
|
|
70707
70722
|
var name = declaration.propertyName || declaration.name;
|
|
70708
70723
|
var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
|
|
70709
|
-
parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent
|
|
70724
|
+
parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent);
|
|
70710
70725
|
if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
|
|
70711
70726
|
return undefined;
|
|
70712
70727
|
if (parent.name.kind === 201 /* ArrayBindingPattern */) {
|
|
@@ -75884,7 +75899,7 @@ var ts;
|
|
|
75884
75899
|
var links = getSymbolLinks(parameter);
|
|
75885
75900
|
if (!links.type) {
|
|
75886
75901
|
var declaration = parameter.valueDeclaration;
|
|
75887
|
-
links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*
|
|
75902
|
+
links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true);
|
|
75888
75903
|
if (declaration.name.kind !== 79 /* Identifier */) {
|
|
75889
75904
|
// if inference didn't come up with anything but unknown, fall back to the binding pattern if present.
|
|
75890
75905
|
if (links.type === unknownType) {
|
|
@@ -77615,11 +77630,11 @@ var ts;
|
|
|
77615
77630
|
}
|
|
77616
77631
|
}
|
|
77617
77632
|
function checkExpressionCached(node, checkMode) {
|
|
77618
|
-
if (checkMode && checkMode !== 0 /* Normal */) {
|
|
77619
|
-
return checkExpression(node, checkMode);
|
|
77620
|
-
}
|
|
77621
77633
|
var links = getNodeLinks(node);
|
|
77622
77634
|
if (!links.resolvedType) {
|
|
77635
|
+
if (checkMode && checkMode !== 0 /* Normal */) {
|
|
77636
|
+
return checkExpression(node, checkMode);
|
|
77637
|
+
}
|
|
77623
77638
|
// When computing a type that we're going to cache, we need to ignore any ongoing control flow
|
|
77624
77639
|
// analysis because variables may have transient types in indeterminable states. Moving flowLoopStart
|
|
77625
77640
|
// to the top of the stack ensures all transient types are computed from a known point.
|
|
@@ -77639,12 +77654,10 @@ var ts;
|
|
|
77639
77654
|
node.kind === 228 /* AsExpression */ ||
|
|
77640
77655
|
ts.isJSDocTypeAssertion(node);
|
|
77641
77656
|
}
|
|
77642
|
-
function checkDeclarationInitializer(declaration,
|
|
77657
|
+
function checkDeclarationInitializer(declaration, contextualType) {
|
|
77643
77658
|
var initializer = ts.getEffectiveInitializer(declaration);
|
|
77644
77659
|
var type = getQuickTypeOfExpression(initializer) ||
|
|
77645
|
-
(contextualType ?
|
|
77646
|
-
checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* Normal */)
|
|
77647
|
-
: checkExpressionCached(initializer, checkMode));
|
|
77660
|
+
(contextualType ? checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, 0 /* Normal */) : checkExpressionCached(initializer));
|
|
77648
77661
|
return ts.isParameter(declaration) && declaration.name.kind === 201 /* ArrayBindingPattern */ &&
|
|
77649
77662
|
isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
|
|
77650
77663
|
padTupleType(type, declaration.name) : type;
|
|
@@ -80584,8 +80597,7 @@ var ts;
|
|
|
80584
80597
|
}
|
|
80585
80598
|
// check private/protected variable access
|
|
80586
80599
|
var parent = node.parent.parent;
|
|
80587
|
-
var
|
|
80588
|
-
var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
|
|
80600
|
+
var parentType = getTypeForBindingElementParent(parent);
|
|
80589
80601
|
var name = node.propertyName || node.name;
|
|
80590
80602
|
if (parentType && !ts.isBindingPattern(name)) {
|
|
80591
80603
|
var exprType = getLiteralTypeFromPropertyName(name);
|
|
@@ -81824,7 +81836,7 @@ var ts;
|
|
|
81824
81836
|
var declaration = catchClause.variableDeclaration;
|
|
81825
81837
|
var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration));
|
|
81826
81838
|
if (typeNode) {
|
|
81827
|
-
var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false
|
|
81839
|
+
var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false);
|
|
81828
81840
|
if (type && !(type.flags & 3 /* AnyOrUnknown */)) {
|
|
81829
81841
|
grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified);
|
|
81830
81842
|
}
|
|
@@ -84510,7 +84522,7 @@ var ts;
|
|
|
84510
84522
|
return errorType;
|
|
84511
84523
|
}
|
|
84512
84524
|
if (ts.isBindingPattern(node)) {
|
|
84513
|
-
return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true
|
|
84525
|
+
return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true) || errorType;
|
|
84514
84526
|
}
|
|
84515
84527
|
if (isInRightSideOfImportOrExportAssignment(node)) {
|
|
84516
84528
|
var symbol = getSymbolAtLocation(node);
|