@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
|
@@ -33560,7 +33560,7 @@ var ts;
|
|
|
33560
33560
|
function parseInitializer() {
|
|
33561
33561
|
return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined;
|
|
33562
33562
|
}
|
|
33563
|
-
function parseAssignmentExpressionOrHigher() {
|
|
33563
|
+
function parseAssignmentExpressionOrHigher(parsingConditionalTrueSide) {
|
|
33564
33564
|
// AssignmentExpression[in,yield]:
|
|
33565
33565
|
// 1) ConditionalExpression[?in,?yield]
|
|
33566
33566
|
// 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
|
|
@@ -33586,7 +33586,7 @@ var ts;
|
|
|
33586
33586
|
// If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
|
|
33587
33587
|
// not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
|
|
33588
33588
|
// with AssignmentExpression if we see one.
|
|
33589
|
-
var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
|
|
33589
|
+
var arrowExpression = tryParseParenthesizedArrowFunctionExpression(parsingConditionalTrueSide) || tryParseAsyncSimpleArrowFunctionExpression();
|
|
33590
33590
|
if (arrowExpression) {
|
|
33591
33591
|
return arrowExpression;
|
|
33592
33592
|
}
|
|
@@ -33605,7 +33605,7 @@ var ts;
|
|
|
33605
33605
|
// parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single
|
|
33606
33606
|
// identifier and the current token is an arrow.
|
|
33607
33607
|
if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) {
|
|
33608
|
-
return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined);
|
|
33608
|
+
return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined, parsingConditionalTrueSide);
|
|
33609
33609
|
}
|
|
33610
33610
|
// Now see if we might be in cases '2' or '3'.
|
|
33611
33611
|
// If the expression was a LHS expression, and we have an assignment operator, then
|
|
@@ -33665,7 +33665,7 @@ var ts;
|
|
|
33665
33665
|
return finishNode(factory.createYieldExpression(/*asteriskToken*/ undefined, /*expression*/ undefined), pos);
|
|
33666
33666
|
}
|
|
33667
33667
|
}
|
|
33668
|
-
function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) {
|
|
33668
|
+
function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier, parsingConditionalTrueSide) {
|
|
33669
33669
|
ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
|
|
33670
33670
|
var parameter = factory.createParameterDeclaration(
|
|
33671
33671
|
/*decorators*/ undefined,
|
|
@@ -33677,11 +33677,11 @@ var ts;
|
|
|
33677
33677
|
finishNode(parameter, identifier.pos);
|
|
33678
33678
|
var parameters = createNodeArray([parameter], parameter.pos, parameter.end);
|
|
33679
33679
|
var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
|
|
33680
|
-
var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier);
|
|
33680
|
+
var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, parsingConditionalTrueSide);
|
|
33681
33681
|
var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body);
|
|
33682
33682
|
return addJSDocComment(finishNode(node, pos));
|
|
33683
33683
|
}
|
|
33684
|
-
function tryParseParenthesizedArrowFunctionExpression() {
|
|
33684
|
+
function tryParseParenthesizedArrowFunctionExpression(parsingConditionalTrueSide) {
|
|
33685
33685
|
var triState = isParenthesizedArrowFunctionExpression();
|
|
33686
33686
|
if (triState === 0 /* False */) {
|
|
33687
33687
|
// It's definitely not a parenthesized arrow function expression.
|
|
@@ -33692,8 +33692,8 @@ var ts;
|
|
|
33692
33692
|
// it out, but don't allow any ambiguity, and return 'undefined' if this could be an
|
|
33693
33693
|
// expression instead.
|
|
33694
33694
|
return triState === 1 /* True */ ?
|
|
33695
|
-
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) :
|
|
33696
|
-
tryParse(parsePossibleParenthesizedArrowFunctionExpression);
|
|
33695
|
+
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, parsingConditionalTrueSide) :
|
|
33696
|
+
tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(parsingConditionalTrueSide); });
|
|
33697
33697
|
}
|
|
33698
33698
|
// True -> We definitely expect a parenthesized arrow function here.
|
|
33699
33699
|
// False -> There *cannot* be a parenthesized arrow function here.
|
|
@@ -33823,25 +33823,25 @@ var ts;
|
|
|
33823
33823
|
return 2 /* Unknown */;
|
|
33824
33824
|
}
|
|
33825
33825
|
}
|
|
33826
|
-
function parsePossibleParenthesizedArrowFunctionExpression() {
|
|
33826
|
+
function parsePossibleParenthesizedArrowFunctionExpression(parsingConditionalTrueSide) {
|
|
33827
33827
|
var tokenPos = scanner.getTokenPos();
|
|
33828
33828
|
if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) {
|
|
33829
33829
|
return undefined;
|
|
33830
33830
|
}
|
|
33831
|
-
var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false);
|
|
33831
|
+
var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false, parsingConditionalTrueSide);
|
|
33832
33832
|
if (!result) {
|
|
33833
33833
|
(notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos);
|
|
33834
33834
|
}
|
|
33835
33835
|
return result;
|
|
33836
33836
|
}
|
|
33837
|
-
function tryParseAsyncSimpleArrowFunctionExpression() {
|
|
33837
|
+
function tryParseAsyncSimpleArrowFunctionExpression(parsingConditionalTrueSide) {
|
|
33838
33838
|
// We do a check here so that we won't be doing unnecessarily call to "lookAhead"
|
|
33839
33839
|
if (token() === 131 /* AsyncKeyword */) {
|
|
33840
33840
|
if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) {
|
|
33841
33841
|
var pos = getNodePos();
|
|
33842
33842
|
var asyncModifier = parseModifiersForArrowFunction();
|
|
33843
33843
|
var expr = parseBinaryExpressionOrHigher(0 /* Lowest */);
|
|
33844
|
-
return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier);
|
|
33844
|
+
return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier, parsingConditionalTrueSide);
|
|
33845
33845
|
}
|
|
33846
33846
|
}
|
|
33847
33847
|
return undefined;
|
|
@@ -33865,7 +33865,7 @@ var ts;
|
|
|
33865
33865
|
}
|
|
33866
33866
|
return 0 /* False */;
|
|
33867
33867
|
}
|
|
33868
|
-
function parseParenthesizedArrowFunctionExpression(allowAmbiguity) {
|
|
33868
|
+
function parseParenthesizedArrowFunctionExpression(allowAmbiguity, parsingConditionalTrueSide) {
|
|
33869
33869
|
var pos = getNodePos();
|
|
33870
33870
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
33871
33871
|
var modifiers = parseModifiersForArrowFunction();
|
|
@@ -33891,6 +33891,18 @@ var ts;
|
|
|
33891
33891
|
return undefined;
|
|
33892
33892
|
}
|
|
33893
33893
|
}
|
|
33894
|
+
// Given:
|
|
33895
|
+
// x ? y => ({ y }) : z => ({ z })
|
|
33896
|
+
// We try to parse the body of the first arrow function by looking at:
|
|
33897
|
+
// ({ y }) : z => ({ z })
|
|
33898
|
+
// This is a valid arrow function with "z" as the return type.
|
|
33899
|
+
//
|
|
33900
|
+
// But, if we're in the true side of a conditional expression, this colon
|
|
33901
|
+
// terminates the true side, so cannot be the return type.
|
|
33902
|
+
if (parsingConditionalTrueSide && token() === 58 /* ColonToken */) {
|
|
33903
|
+
ts.Debug.assert(!allowAmbiguity);
|
|
33904
|
+
return undefined;
|
|
33905
|
+
}
|
|
33894
33906
|
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
|
33895
33907
|
if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
|
|
33896
33908
|
return undefined;
|
|
@@ -33924,7 +33936,7 @@ var ts;
|
|
|
33924
33936
|
var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
|
|
33925
33937
|
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
|
33926
33938
|
}
|
|
33927
|
-
function parseArrowFunctionExpressionBody(isAsync) {
|
|
33939
|
+
function parseArrowFunctionExpressionBody(isAsync, parsingConditionalTrueSide) {
|
|
33928
33940
|
if (token() === 18 /* OpenBraceToken */) {
|
|
33929
33941
|
return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */);
|
|
33930
33942
|
}
|
|
@@ -33952,8 +33964,8 @@ var ts;
|
|
|
33952
33964
|
var savedTopLevel = topLevel;
|
|
33953
33965
|
topLevel = false;
|
|
33954
33966
|
var node = isAsync
|
|
33955
|
-
? doInAwaitContext(parseAssignmentExpressionOrHigher)
|
|
33956
|
-
: doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
|
|
33967
|
+
? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(parsingConditionalTrueSide); })
|
|
33968
|
+
: doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(parsingConditionalTrueSide); });
|
|
33957
33969
|
topLevel = savedTopLevel;
|
|
33958
33970
|
return node;
|
|
33959
33971
|
}
|
|
@@ -33966,8 +33978,8 @@ var ts;
|
|
|
33966
33978
|
// Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and
|
|
33967
33979
|
// we do not that for the 'whenFalse' part.
|
|
33968
33980
|
var colonToken;
|
|
33969
|
-
return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
|
|
33970
|
-
? parseAssignmentExpressionOrHigher()
|
|
33981
|
+
return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*parsingConditionalTrueSide*/ true); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
|
|
33982
|
+
? parseAssignmentExpressionOrHigher(/*parsingConditionalTrueSide*/ false)
|
|
33971
33983
|
: createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos);
|
|
33972
33984
|
}
|
|
33973
33985
|
function parseBinaryExpressionOrHigher(precedence) {
|
|
@@ -46982,6 +46994,9 @@ var ts;
|
|
|
46982
46994
|
TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts";
|
|
46983
46995
|
TypeFacts[TypeFacts["AllTypeofNE"] = 556800] = "AllTypeofNE";
|
|
46984
46996
|
TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts";
|
|
46997
|
+
// Masks
|
|
46998
|
+
TypeFacts[TypeFacts["OrFactsMask"] = 8288] = "OrFactsMask";
|
|
46999
|
+
TypeFacts[TypeFacts["AndFactsMask"] = 16768927] = "AndFactsMask";
|
|
46985
47000
|
})(TypeFacts || (TypeFacts = {}));
|
|
46986
47001
|
var typeofEQFacts = new ts.Map(ts.getEntries({
|
|
46987
47002
|
string: 1 /* TypeofEQString */,
|
|
@@ -47022,10 +47037,6 @@ var ts;
|
|
|
47022
47037
|
CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
47023
47038
|
CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
47024
47039
|
CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
|
47025
|
-
CheckMode[CheckMode["ObjectRestBindingElement"] = 32] = "ObjectRestBindingElement";
|
|
47026
|
-
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
|
|
47027
|
-
// we need to preserve generic types instead of substituting them for constraints
|
|
47028
|
-
CheckMode[CheckMode["IncludeOptionality"] = 64] = "IncludeOptionality";
|
|
47029
47040
|
})(CheckMode || (CheckMode = {}));
|
|
47030
47041
|
var SignatureCheckMode;
|
|
47031
47042
|
(function (SignatureCheckMode) {
|
|
@@ -54450,12 +54461,9 @@ var ts;
|
|
|
54450
54461
|
}
|
|
54451
54462
|
// Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
|
|
54452
54463
|
// assigned by contextual typing.
|
|
54453
|
-
function getTypeForBindingElementParent(node
|
|
54454
|
-
if (checkMode && checkMode !== 0 /* Normal */) {
|
|
54455
|
-
return getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode);
|
|
54456
|
-
}
|
|
54464
|
+
function getTypeForBindingElementParent(node) {
|
|
54457
54465
|
var symbol = getSymbolOfNode(node);
|
|
54458
|
-
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false
|
|
54466
|
+
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false);
|
|
54459
54467
|
}
|
|
54460
54468
|
function getRestType(source, properties, symbol) {
|
|
54461
54469
|
source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); });
|
|
@@ -54573,8 +54581,7 @@ var ts;
|
|
|
54573
54581
|
}
|
|
54574
54582
|
/** Return the inferred type for a binding element */
|
|
54575
54583
|
function getTypeForBindingElement(declaration) {
|
|
54576
|
-
var
|
|
54577
|
-
var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
54584
|
+
var parentType = getTypeForBindingElementParent(declaration.parent.parent);
|
|
54578
54585
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
54579
54586
|
}
|
|
54580
54587
|
function getBindingElementTypeFromParentType(declaration, parentType) {
|
|
@@ -54646,9 +54653,9 @@ var ts;
|
|
|
54646
54653
|
if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
|
|
54647
54654
|
// In strict null checking mode, if a default value of a non-undefined type is specified, remove
|
|
54648
54655
|
// undefined from the final type.
|
|
54649
|
-
return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration
|
|
54656
|
+
return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
|
|
54650
54657
|
}
|
|
54651
|
-
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration
|
|
54658
|
+
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2 /* Subtype */));
|
|
54652
54659
|
}
|
|
54653
54660
|
function getTypeForDeclarationFromJSDocComment(declaration) {
|
|
54654
54661
|
var jsdocType = ts.getJSDocType(declaration);
|
|
@@ -54671,12 +54678,11 @@ var ts;
|
|
|
54671
54678
|
return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type;
|
|
54672
54679
|
}
|
|
54673
54680
|
// Return the inferred type for a variable, parameter, or property declaration
|
|
54674
|
-
function getTypeForVariableLikeDeclaration(declaration, includeOptionality
|
|
54675
|
-
checkMode) {
|
|
54681
|
+
function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
|
|
54676
54682
|
// A variable declared in a for..in statement is of type string, or of type keyof T when the
|
|
54677
54683
|
// right hand expression is of a type parameter type.
|
|
54678
54684
|
if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 242 /* ForInStatement */) {
|
|
54679
|
-
var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression
|
|
54685
|
+
var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression)));
|
|
54680
54686
|
return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType;
|
|
54681
54687
|
}
|
|
54682
54688
|
if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForOfStatement */) {
|
|
@@ -54753,7 +54759,7 @@ var ts;
|
|
|
54753
54759
|
return containerObjectType;
|
|
54754
54760
|
}
|
|
54755
54761
|
}
|
|
54756
|
-
var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration
|
|
54762
|
+
var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration));
|
|
54757
54763
|
return addOptionality(type, isProperty, isOptional);
|
|
54758
54764
|
}
|
|
54759
54765
|
if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) {
|
|
@@ -55125,7 +55131,7 @@ var ts;
|
|
|
55125
55131
|
// contextual type or, if the element itself is a binding pattern, with the type implied by that binding
|
|
55126
55132
|
// pattern.
|
|
55127
55133
|
var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType;
|
|
55128
|
-
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element,
|
|
55134
|
+
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, contextualType)));
|
|
55129
55135
|
}
|
|
55130
55136
|
if (ts.isBindingPattern(element.name)) {
|
|
55131
55137
|
return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
|
|
@@ -55214,7 +55220,7 @@ var ts;
|
|
|
55214
55220
|
// binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the
|
|
55215
55221
|
// tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string.
|
|
55216
55222
|
function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
|
|
55217
|
-
return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true
|
|
55223
|
+
return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true), declaration, reportErrors);
|
|
55218
55224
|
}
|
|
55219
55225
|
function isGlobalSymbolConstructor(node) {
|
|
55220
55226
|
var symbol = getSymbolOfNode(node);
|
|
@@ -68132,10 +68138,23 @@ var ts;
|
|
|
68132
68138
|
// When an intersection contains a primitive type we ignore object type constituents as they are
|
|
68133
68139
|
// presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type.
|
|
68134
68140
|
ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */));
|
|
68135
|
-
return
|
|
68141
|
+
return getIntersectionTypeFacts(type, ignoreObjects);
|
|
68136
68142
|
}
|
|
68137
68143
|
return 16777215 /* All */;
|
|
68138
68144
|
}
|
|
68145
|
+
function getIntersectionTypeFacts(type, ignoreObjects) {
|
|
68146
|
+
// When computing the type facts of an intersection type, certain type facts are computed as `and`
|
|
68147
|
+
// and others are computed as `or`.
|
|
68148
|
+
var oredFacts = 0 /* None */;
|
|
68149
|
+
var andedFacts = 16777215 /* All */;
|
|
68150
|
+
for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
|
|
68151
|
+
var t = _a[_i];
|
|
68152
|
+
var f = getTypeFacts(t, ignoreObjects);
|
|
68153
|
+
oredFacts |= f;
|
|
68154
|
+
andedFacts &= f;
|
|
68155
|
+
}
|
|
68156
|
+
return oredFacts & 8288 /* OrFactsMask */ | andedFacts & 16768927 /* AndFactsMask */;
|
|
68157
|
+
}
|
|
68139
68158
|
function getTypeWithFacts(type, include) {
|
|
68140
68159
|
return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
|
|
68141
68160
|
}
|
|
@@ -69960,16 +69979,12 @@ var ts;
|
|
|
69960
69979
|
function isGenericTypeWithoutNullableConstraint(type) {
|
|
69961
69980
|
return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
69962
69981
|
}
|
|
69963
|
-
function
|
|
69982
|
+
function hasNonBindingPatternContextualTypeWithNoGenericTypes(node) {
|
|
69964
69983
|
// Computing the contextual type for a child of a JSX element involves resolving the type of the
|
|
69965
69984
|
// element's tag name, so we exclude that here to avoid circularities.
|
|
69966
|
-
// If check mode has `CheckMode.ObjectRestBindingElement`, we skip binding pattern contextual types,
|
|
69967
|
-
// as we want the type of a rest element to be generic when possible.
|
|
69968
69985
|
var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
|
|
69969
69986
|
!((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
|
|
69970
|
-
(
|
|
69971
|
-
getContextualType(node, 8 /* SkipBindingPatterns */)
|
|
69972
|
-
: getContextualType(node));
|
|
69987
|
+
getContextualType(node, 8 /* SkipBindingPatterns */);
|
|
69973
69988
|
return contextualType && !isGenericType(contextualType);
|
|
69974
69989
|
}
|
|
69975
69990
|
function getNarrowableTypeForReference(type, reference, checkMode) {
|
|
@@ -69982,7 +69997,7 @@ var ts;
|
|
|
69982
69997
|
// 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'.
|
|
69983
69998
|
var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
|
|
69984
69999
|
someType(type, isGenericTypeWithUnionConstraint) &&
|
|
69985
|
-
(isConstraintPosition(type, reference) ||
|
|
70000
|
+
(isConstraintPosition(type, reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference));
|
|
69986
70001
|
return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
|
|
69987
70002
|
}
|
|
69988
70003
|
function isExportOrExportExpression(location) {
|
|
@@ -70050,7 +70065,7 @@ var ts;
|
|
|
70050
70065
|
var links = getNodeLinks(location);
|
|
70051
70066
|
if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
|
|
70052
70067
|
links.flags |= 268435456 /* InCheckIdentifier */;
|
|
70053
|
-
var parentType = getTypeForBindingElementParent(parent
|
|
70068
|
+
var parentType = getTypeForBindingElementParent(parent);
|
|
70054
70069
|
links.flags &= ~268435456 /* InCheckIdentifier */;
|
|
70055
70070
|
if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
|
|
70056
70071
|
var pattern = declaration.parent;
|
|
@@ -70900,7 +70915,7 @@ var ts;
|
|
|
70900
70915
|
var parent = declaration.parent.parent;
|
|
70901
70916
|
var name = declaration.propertyName || declaration.name;
|
|
70902
70917
|
var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
|
|
70903
|
-
parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent
|
|
70918
|
+
parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent);
|
|
70904
70919
|
if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
|
|
70905
70920
|
return undefined;
|
|
70906
70921
|
if (parent.name.kind === 201 /* ArrayBindingPattern */) {
|
|
@@ -76078,7 +76093,7 @@ var ts;
|
|
|
76078
76093
|
var links = getSymbolLinks(parameter);
|
|
76079
76094
|
if (!links.type) {
|
|
76080
76095
|
var declaration = parameter.valueDeclaration;
|
|
76081
|
-
links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*
|
|
76096
|
+
links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true);
|
|
76082
76097
|
if (declaration.name.kind !== 79 /* Identifier */) {
|
|
76083
76098
|
// if inference didn't come up with anything but unknown, fall back to the binding pattern if present.
|
|
76084
76099
|
if (links.type === unknownType) {
|
|
@@ -77809,11 +77824,11 @@ var ts;
|
|
|
77809
77824
|
}
|
|
77810
77825
|
}
|
|
77811
77826
|
function checkExpressionCached(node, checkMode) {
|
|
77812
|
-
if (checkMode && checkMode !== 0 /* Normal */) {
|
|
77813
|
-
return checkExpression(node, checkMode);
|
|
77814
|
-
}
|
|
77815
77827
|
var links = getNodeLinks(node);
|
|
77816
77828
|
if (!links.resolvedType) {
|
|
77829
|
+
if (checkMode && checkMode !== 0 /* Normal */) {
|
|
77830
|
+
return checkExpression(node, checkMode);
|
|
77831
|
+
}
|
|
77817
77832
|
// When computing a type that we're going to cache, we need to ignore any ongoing control flow
|
|
77818
77833
|
// analysis because variables may have transient types in indeterminable states. Moving flowLoopStart
|
|
77819
77834
|
// to the top of the stack ensures all transient types are computed from a known point.
|
|
@@ -77833,12 +77848,10 @@ var ts;
|
|
|
77833
77848
|
node.kind === 228 /* AsExpression */ ||
|
|
77834
77849
|
ts.isJSDocTypeAssertion(node);
|
|
77835
77850
|
}
|
|
77836
|
-
function checkDeclarationInitializer(declaration,
|
|
77851
|
+
function checkDeclarationInitializer(declaration, contextualType) {
|
|
77837
77852
|
var initializer = ts.getEffectiveInitializer(declaration);
|
|
77838
77853
|
var type = getQuickTypeOfExpression(initializer) ||
|
|
77839
|
-
(contextualType ?
|
|
77840
|
-
checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* Normal */)
|
|
77841
|
-
: checkExpressionCached(initializer, checkMode));
|
|
77854
|
+
(contextualType ? checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, 0 /* Normal */) : checkExpressionCached(initializer));
|
|
77842
77855
|
return ts.isParameter(declaration) && declaration.name.kind === 201 /* ArrayBindingPattern */ &&
|
|
77843
77856
|
isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
|
|
77844
77857
|
padTupleType(type, declaration.name) : type;
|
|
@@ -80778,8 +80791,7 @@ var ts;
|
|
|
80778
80791
|
}
|
|
80779
80792
|
// check private/protected variable access
|
|
80780
80793
|
var parent = node.parent.parent;
|
|
80781
|
-
var
|
|
80782
|
-
var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
|
|
80794
|
+
var parentType = getTypeForBindingElementParent(parent);
|
|
80783
80795
|
var name = node.propertyName || node.name;
|
|
80784
80796
|
if (parentType && !ts.isBindingPattern(name)) {
|
|
80785
80797
|
var exprType = getLiteralTypeFromPropertyName(name);
|
|
@@ -82018,7 +82030,7 @@ var ts;
|
|
|
82018
82030
|
var declaration = catchClause.variableDeclaration;
|
|
82019
82031
|
var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration));
|
|
82020
82032
|
if (typeNode) {
|
|
82021
|
-
var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false
|
|
82033
|
+
var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false);
|
|
82022
82034
|
if (type && !(type.flags & 3 /* AnyOrUnknown */)) {
|
|
82023
82035
|
grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified);
|
|
82024
82036
|
}
|
|
@@ -84704,7 +84716,7 @@ var ts;
|
|
|
84704
84716
|
return errorType;
|
|
84705
84717
|
}
|
|
84706
84718
|
if (ts.isBindingPattern(node)) {
|
|
84707
|
-
return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true
|
|
84719
|
+
return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true) || errorType;
|
|
84708
84720
|
}
|
|
84709
84721
|
if (isInRightSideOfImportOrExportAssignment(node)) {
|
|
84710
84722
|
var symbol = getSymbolAtLocation(node);
|