@typescript-deploys/pr-build 4.6.0-pr-47548-5 → 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/lib.es5.d.ts +0 -5
- package/lib/tsc.js +30 -34
- package/lib/tsserver.js +40 -34
- package/lib/tsserverlibrary.js +40 -34
- package/lib/typescript.js +40 -34
- package/lib/typescriptServices.js +40 -34
- package/lib/typingsInstaller.js +40 -34
- package/package.json +1 -1
package/lib/typescript.js
CHANGED
|
@@ -305,13 +305,18 @@ var ts;
|
|
|
305
305
|
/* @internal */
|
|
306
306
|
var NativeCollections;
|
|
307
307
|
(function (NativeCollections) {
|
|
308
|
+
var globals = typeof globalThis !== "undefined" ? globalThis :
|
|
309
|
+
typeof global !== "undefined" ? global :
|
|
310
|
+
typeof self !== "undefined" ? self :
|
|
311
|
+
undefined;
|
|
308
312
|
/**
|
|
309
313
|
* Returns the native Map implementation if it is available and compatible (i.e. supports iteration).
|
|
310
314
|
*/
|
|
311
315
|
function tryGetNativeMap() {
|
|
312
316
|
// Internet Explorer's Map doesn't support iteration, so don't use it.
|
|
317
|
+
var gMap = globals === null || globals === void 0 ? void 0 : globals.Map;
|
|
313
318
|
// eslint-disable-next-line no-in-operator
|
|
314
|
-
return typeof
|
|
319
|
+
return typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
|
|
315
320
|
}
|
|
316
321
|
NativeCollections.tryGetNativeMap = tryGetNativeMap;
|
|
317
322
|
/**
|
|
@@ -319,8 +324,9 @@ var ts;
|
|
|
319
324
|
*/
|
|
320
325
|
function tryGetNativeSet() {
|
|
321
326
|
// Internet Explorer's Set doesn't support iteration, so don't use it.
|
|
327
|
+
var gSet = globals === null || globals === void 0 ? void 0 : globals.Set;
|
|
322
328
|
// eslint-disable-next-line no-in-operator
|
|
323
|
-
return typeof
|
|
329
|
+
return typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
|
|
324
330
|
}
|
|
325
331
|
NativeCollections.tryGetNativeSet = tryGetNativeSet;
|
|
326
332
|
})(NativeCollections || (NativeCollections = {}));
|
|
@@ -33560,7 +33566,7 @@ var ts;
|
|
|
33560
33566
|
function parseInitializer() {
|
|
33561
33567
|
return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined;
|
|
33562
33568
|
}
|
|
33563
|
-
function parseAssignmentExpressionOrHigher() {
|
|
33569
|
+
function parseAssignmentExpressionOrHigher(parsingConditionalExpression) {
|
|
33564
33570
|
// AssignmentExpression[in,yield]:
|
|
33565
33571
|
// 1) ConditionalExpression[?in,?yield]
|
|
33566
33572
|
// 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
|
|
@@ -33586,7 +33592,7 @@ var ts;
|
|
|
33586
33592
|
// If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
|
|
33587
33593
|
// not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
|
|
33588
33594
|
// with AssignmentExpression if we see one.
|
|
33589
|
-
var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
|
|
33595
|
+
var arrowExpression = tryParseParenthesizedArrowFunctionExpression(parsingConditionalExpression) || tryParseAsyncSimpleArrowFunctionExpression();
|
|
33590
33596
|
if (arrowExpression) {
|
|
33591
33597
|
return arrowExpression;
|
|
33592
33598
|
}
|
|
@@ -33605,7 +33611,7 @@ var ts;
|
|
|
33605
33611
|
// parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single
|
|
33606
33612
|
// identifier and the current token is an arrow.
|
|
33607
33613
|
if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) {
|
|
33608
|
-
return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined);
|
|
33614
|
+
return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined, parsingConditionalExpression);
|
|
33609
33615
|
}
|
|
33610
33616
|
// Now see if we might be in cases '2' or '3'.
|
|
33611
33617
|
// If the expression was a LHS expression, and we have an assignment operator, then
|
|
@@ -33665,7 +33671,7 @@ var ts;
|
|
|
33665
33671
|
return finishNode(factory.createYieldExpression(/*asteriskToken*/ undefined, /*expression*/ undefined), pos);
|
|
33666
33672
|
}
|
|
33667
33673
|
}
|
|
33668
|
-
function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) {
|
|
33674
|
+
function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier, parsingConditionalExpression) {
|
|
33669
33675
|
ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
|
|
33670
33676
|
var parameter = factory.createParameterDeclaration(
|
|
33671
33677
|
/*decorators*/ undefined,
|
|
@@ -33677,11 +33683,11 @@ var ts;
|
|
|
33677
33683
|
finishNode(parameter, identifier.pos);
|
|
33678
33684
|
var parameters = createNodeArray([parameter], parameter.pos, parameter.end);
|
|
33679
33685
|
var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
|
|
33680
|
-
var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier);
|
|
33686
|
+
var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, parsingConditionalExpression);
|
|
33681
33687
|
var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body);
|
|
33682
33688
|
return addJSDocComment(finishNode(node, pos));
|
|
33683
33689
|
}
|
|
33684
|
-
function tryParseParenthesizedArrowFunctionExpression() {
|
|
33690
|
+
function tryParseParenthesizedArrowFunctionExpression(parsingConditionalExpression) {
|
|
33685
33691
|
var triState = isParenthesizedArrowFunctionExpression();
|
|
33686
33692
|
if (triState === 0 /* False */) {
|
|
33687
33693
|
// It's definitely not a parenthesized arrow function expression.
|
|
@@ -33692,8 +33698,8 @@ var ts;
|
|
|
33692
33698
|
// it out, but don't allow any ambiguity, and return 'undefined' if this could be an
|
|
33693
33699
|
// expression instead.
|
|
33694
33700
|
return triState === 1 /* True */ ?
|
|
33695
|
-
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) :
|
|
33696
|
-
tryParse(parsePossibleParenthesizedArrowFunctionExpression);
|
|
33701
|
+
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, parsingConditionalExpression) :
|
|
33702
|
+
tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(parsingConditionalExpression); });
|
|
33697
33703
|
}
|
|
33698
33704
|
// True -> We definitely expect a parenthesized arrow function here.
|
|
33699
33705
|
// False -> There *cannot* be a parenthesized arrow function here.
|
|
@@ -33823,25 +33829,25 @@ var ts;
|
|
|
33823
33829
|
return 2 /* Unknown */;
|
|
33824
33830
|
}
|
|
33825
33831
|
}
|
|
33826
|
-
function parsePossibleParenthesizedArrowFunctionExpression() {
|
|
33832
|
+
function parsePossibleParenthesizedArrowFunctionExpression(parsingConditionalExpression) {
|
|
33827
33833
|
var tokenPos = scanner.getTokenPos();
|
|
33828
33834
|
if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) {
|
|
33829
33835
|
return undefined;
|
|
33830
33836
|
}
|
|
33831
|
-
var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false);
|
|
33837
|
+
var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false, parsingConditionalExpression);
|
|
33832
33838
|
if (!result) {
|
|
33833
33839
|
(notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos);
|
|
33834
33840
|
}
|
|
33835
33841
|
return result;
|
|
33836
33842
|
}
|
|
33837
|
-
function tryParseAsyncSimpleArrowFunctionExpression() {
|
|
33843
|
+
function tryParseAsyncSimpleArrowFunctionExpression(parsingConditionalExpression) {
|
|
33838
33844
|
// We do a check here so that we won't be doing unnecessarily call to "lookAhead"
|
|
33839
33845
|
if (token() === 131 /* AsyncKeyword */) {
|
|
33840
33846
|
if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) {
|
|
33841
33847
|
var pos = getNodePos();
|
|
33842
33848
|
var asyncModifier = parseModifiersForArrowFunction();
|
|
33843
33849
|
var expr = parseBinaryExpressionOrHigher(0 /* Lowest */);
|
|
33844
|
-
return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier);
|
|
33850
|
+
return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier, parsingConditionalExpression);
|
|
33845
33851
|
}
|
|
33846
33852
|
}
|
|
33847
33853
|
return undefined;
|
|
@@ -33865,7 +33871,7 @@ var ts;
|
|
|
33865
33871
|
}
|
|
33866
33872
|
return 0 /* False */;
|
|
33867
33873
|
}
|
|
33868
|
-
function parseParenthesizedArrowFunctionExpression(allowAmbiguity) {
|
|
33874
|
+
function parseParenthesizedArrowFunctionExpression(allowAmbiguity, parsingConditionalExpression) {
|
|
33869
33875
|
var pos = getNodePos();
|
|
33870
33876
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
33871
33877
|
var modifiers = parseModifiersForArrowFunction();
|
|
@@ -33891,6 +33897,20 @@ var ts;
|
|
|
33891
33897
|
return undefined;
|
|
33892
33898
|
}
|
|
33893
33899
|
}
|
|
33900
|
+
// Given:
|
|
33901
|
+
// x ? y => ({ y }) : z => ({ z })
|
|
33902
|
+
// We try to parse the body of the first arrow function by looking at:
|
|
33903
|
+
// ({ y }) : z => ({ z })
|
|
33904
|
+
// This is a valid arrow function with "z" as the return type.
|
|
33905
|
+
//
|
|
33906
|
+
// But, if we're in the true side of a conditional expression, this colon
|
|
33907
|
+
// terminates the true side, so cannot be the return type. If we are in the
|
|
33908
|
+
// false side, we may still be within the true side of a parent conditional
|
|
33909
|
+
// expression, so don't allow it to be a return type either.
|
|
33910
|
+
if (parsingConditionalExpression && token() === 58 /* ColonToken */) {
|
|
33911
|
+
ts.Debug.assert(!allowAmbiguity);
|
|
33912
|
+
return undefined;
|
|
33913
|
+
}
|
|
33894
33914
|
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
|
33895
33915
|
if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
|
|
33896
33916
|
return undefined;
|
|
@@ -33924,7 +33944,7 @@ var ts;
|
|
|
33924
33944
|
var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
|
|
33925
33945
|
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
|
33926
33946
|
}
|
|
33927
|
-
function parseArrowFunctionExpressionBody(isAsync) {
|
|
33947
|
+
function parseArrowFunctionExpressionBody(isAsync, parsingConditionalExpression) {
|
|
33928
33948
|
if (token() === 18 /* OpenBraceToken */) {
|
|
33929
33949
|
return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */);
|
|
33930
33950
|
}
|
|
@@ -33952,8 +33972,8 @@ var ts;
|
|
|
33952
33972
|
var savedTopLevel = topLevel;
|
|
33953
33973
|
topLevel = false;
|
|
33954
33974
|
var node = isAsync
|
|
33955
|
-
? doInAwaitContext(parseAssignmentExpressionOrHigher)
|
|
33956
|
-
: doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
|
|
33975
|
+
? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(parsingConditionalExpression); })
|
|
33976
|
+
: doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(parsingConditionalExpression); });
|
|
33957
33977
|
topLevel = savedTopLevel;
|
|
33958
33978
|
return node;
|
|
33959
33979
|
}
|
|
@@ -33966,8 +33986,8 @@ var ts;
|
|
|
33966
33986
|
// Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and
|
|
33967
33987
|
// we do not that for the 'whenFalse' part.
|
|
33968
33988
|
var colonToken;
|
|
33969
|
-
return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
|
|
33970
|
-
? parseAssignmentExpressionOrHigher()
|
|
33989
|
+
return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*parsingConditionalExpression*/ true); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
|
|
33990
|
+
? parseAssignmentExpressionOrHigher(/*parsingConditionalExpression*/ true)
|
|
33971
33991
|
: createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos);
|
|
33972
33992
|
}
|
|
33973
33993
|
function parseBinaryExpressionOrHigher(precedence) {
|
|
@@ -47701,7 +47721,6 @@ var ts;
|
|
|
47701
47721
|
var globalBooleanType;
|
|
47702
47722
|
var globalRegExpType;
|
|
47703
47723
|
var globalThisType;
|
|
47704
|
-
var globalYieldType;
|
|
47705
47724
|
var anyArrayType;
|
|
47706
47725
|
var autoArrayType;
|
|
47707
47726
|
var anyReadonlyArrayType;
|
|
@@ -70794,14 +70813,6 @@ var ts;
|
|
|
70794
70813
|
return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t);
|
|
70795
70814
|
});
|
|
70796
70815
|
}
|
|
70797
|
-
function getYieldTypeArgument(type) {
|
|
70798
|
-
return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalYieldType ? getTypeArguments(type)[0] : undefined;
|
|
70799
|
-
}
|
|
70800
|
-
function getYieldTypeFromContextualType(type) {
|
|
70801
|
-
return mapType(type, function (t) {
|
|
70802
|
-
return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getYieldTypeArgument) : getYieldTypeArgument(t);
|
|
70803
|
-
});
|
|
70804
|
-
}
|
|
70805
70816
|
function getContextualThisParameterType(func) {
|
|
70806
70817
|
if (func.kind === 213 /* ArrowFunction */) {
|
|
70807
70818
|
return undefined;
|
|
@@ -77745,10 +77756,6 @@ var ts;
|
|
|
77745
77756
|
return getIterationTypeOfIterable(use, 1 /* Return */, yieldExpressionType, node.expression)
|
|
77746
77757
|
|| anyType;
|
|
77747
77758
|
}
|
|
77748
|
-
var suggestedReturnType = yieldedType && getYieldTypeFromContextualType(yieldedType);
|
|
77749
|
-
if (suggestedReturnType) {
|
|
77750
|
-
return suggestedReturnType;
|
|
77751
|
-
}
|
|
77752
77759
|
else if (returnType) {
|
|
77753
77760
|
return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync)
|
|
77754
77761
|
|| anyType;
|
|
@@ -85687,7 +85694,6 @@ var ts;
|
|
|
85687
85694
|
globalReadonlyArrayType = getGlobalTypeOrUndefined("ReadonlyArray", /*arity*/ 1) || globalArrayType;
|
|
85688
85695
|
anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType;
|
|
85689
85696
|
globalThisType = getGlobalTypeOrUndefined("ThisType", /*arity*/ 1);
|
|
85690
|
-
globalYieldType = getGlobalTypeOrUndefined("YieldType", /*arity*/ 1);
|
|
85691
85697
|
if (augmentations) {
|
|
85692
85698
|
// merge _nonglobal_ module augmentations.
|
|
85693
85699
|
// this needs to be done after global symbol table is initialized to make sure that all ambient modules are indexed
|
|
@@ -305,13 +305,18 @@ var ts;
|
|
|
305
305
|
/* @internal */
|
|
306
306
|
var NativeCollections;
|
|
307
307
|
(function (NativeCollections) {
|
|
308
|
+
var globals = typeof globalThis !== "undefined" ? globalThis :
|
|
309
|
+
typeof global !== "undefined" ? global :
|
|
310
|
+
typeof self !== "undefined" ? self :
|
|
311
|
+
undefined;
|
|
308
312
|
/**
|
|
309
313
|
* Returns the native Map implementation if it is available and compatible (i.e. supports iteration).
|
|
310
314
|
*/
|
|
311
315
|
function tryGetNativeMap() {
|
|
312
316
|
// Internet Explorer's Map doesn't support iteration, so don't use it.
|
|
317
|
+
var gMap = globals === null || globals === void 0 ? void 0 : globals.Map;
|
|
313
318
|
// eslint-disable-next-line no-in-operator
|
|
314
|
-
return typeof
|
|
319
|
+
return typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
|
|
315
320
|
}
|
|
316
321
|
NativeCollections.tryGetNativeMap = tryGetNativeMap;
|
|
317
322
|
/**
|
|
@@ -319,8 +324,9 @@ var ts;
|
|
|
319
324
|
*/
|
|
320
325
|
function tryGetNativeSet() {
|
|
321
326
|
// Internet Explorer's Set doesn't support iteration, so don't use it.
|
|
327
|
+
var gSet = globals === null || globals === void 0 ? void 0 : globals.Set;
|
|
322
328
|
// eslint-disable-next-line no-in-operator
|
|
323
|
-
return typeof
|
|
329
|
+
return typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
|
|
324
330
|
}
|
|
325
331
|
NativeCollections.tryGetNativeSet = tryGetNativeSet;
|
|
326
332
|
})(NativeCollections || (NativeCollections = {}));
|
|
@@ -33560,7 +33566,7 @@ var ts;
|
|
|
33560
33566
|
function parseInitializer() {
|
|
33561
33567
|
return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined;
|
|
33562
33568
|
}
|
|
33563
|
-
function parseAssignmentExpressionOrHigher() {
|
|
33569
|
+
function parseAssignmentExpressionOrHigher(parsingConditionalExpression) {
|
|
33564
33570
|
// AssignmentExpression[in,yield]:
|
|
33565
33571
|
// 1) ConditionalExpression[?in,?yield]
|
|
33566
33572
|
// 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
|
|
@@ -33586,7 +33592,7 @@ var ts;
|
|
|
33586
33592
|
// If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
|
|
33587
33593
|
// not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
|
|
33588
33594
|
// with AssignmentExpression if we see one.
|
|
33589
|
-
var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
|
|
33595
|
+
var arrowExpression = tryParseParenthesizedArrowFunctionExpression(parsingConditionalExpression) || tryParseAsyncSimpleArrowFunctionExpression();
|
|
33590
33596
|
if (arrowExpression) {
|
|
33591
33597
|
return arrowExpression;
|
|
33592
33598
|
}
|
|
@@ -33605,7 +33611,7 @@ var ts;
|
|
|
33605
33611
|
// parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single
|
|
33606
33612
|
// identifier and the current token is an arrow.
|
|
33607
33613
|
if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) {
|
|
33608
|
-
return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined);
|
|
33614
|
+
return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined, parsingConditionalExpression);
|
|
33609
33615
|
}
|
|
33610
33616
|
// Now see if we might be in cases '2' or '3'.
|
|
33611
33617
|
// If the expression was a LHS expression, and we have an assignment operator, then
|
|
@@ -33665,7 +33671,7 @@ var ts;
|
|
|
33665
33671
|
return finishNode(factory.createYieldExpression(/*asteriskToken*/ undefined, /*expression*/ undefined), pos);
|
|
33666
33672
|
}
|
|
33667
33673
|
}
|
|
33668
|
-
function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) {
|
|
33674
|
+
function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier, parsingConditionalExpression) {
|
|
33669
33675
|
ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
|
|
33670
33676
|
var parameter = factory.createParameterDeclaration(
|
|
33671
33677
|
/*decorators*/ undefined,
|
|
@@ -33677,11 +33683,11 @@ var ts;
|
|
|
33677
33683
|
finishNode(parameter, identifier.pos);
|
|
33678
33684
|
var parameters = createNodeArray([parameter], parameter.pos, parameter.end);
|
|
33679
33685
|
var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
|
|
33680
|
-
var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier);
|
|
33686
|
+
var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, parsingConditionalExpression);
|
|
33681
33687
|
var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body);
|
|
33682
33688
|
return addJSDocComment(finishNode(node, pos));
|
|
33683
33689
|
}
|
|
33684
|
-
function tryParseParenthesizedArrowFunctionExpression() {
|
|
33690
|
+
function tryParseParenthesizedArrowFunctionExpression(parsingConditionalExpression) {
|
|
33685
33691
|
var triState = isParenthesizedArrowFunctionExpression();
|
|
33686
33692
|
if (triState === 0 /* False */) {
|
|
33687
33693
|
// It's definitely not a parenthesized arrow function expression.
|
|
@@ -33692,8 +33698,8 @@ var ts;
|
|
|
33692
33698
|
// it out, but don't allow any ambiguity, and return 'undefined' if this could be an
|
|
33693
33699
|
// expression instead.
|
|
33694
33700
|
return triState === 1 /* True */ ?
|
|
33695
|
-
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) :
|
|
33696
|
-
tryParse(parsePossibleParenthesizedArrowFunctionExpression);
|
|
33701
|
+
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, parsingConditionalExpression) :
|
|
33702
|
+
tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(parsingConditionalExpression); });
|
|
33697
33703
|
}
|
|
33698
33704
|
// True -> We definitely expect a parenthesized arrow function here.
|
|
33699
33705
|
// False -> There *cannot* be a parenthesized arrow function here.
|
|
@@ -33823,25 +33829,25 @@ var ts;
|
|
|
33823
33829
|
return 2 /* Unknown */;
|
|
33824
33830
|
}
|
|
33825
33831
|
}
|
|
33826
|
-
function parsePossibleParenthesizedArrowFunctionExpression() {
|
|
33832
|
+
function parsePossibleParenthesizedArrowFunctionExpression(parsingConditionalExpression) {
|
|
33827
33833
|
var tokenPos = scanner.getTokenPos();
|
|
33828
33834
|
if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) {
|
|
33829
33835
|
return undefined;
|
|
33830
33836
|
}
|
|
33831
|
-
var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false);
|
|
33837
|
+
var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false, parsingConditionalExpression);
|
|
33832
33838
|
if (!result) {
|
|
33833
33839
|
(notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos);
|
|
33834
33840
|
}
|
|
33835
33841
|
return result;
|
|
33836
33842
|
}
|
|
33837
|
-
function tryParseAsyncSimpleArrowFunctionExpression() {
|
|
33843
|
+
function tryParseAsyncSimpleArrowFunctionExpression(parsingConditionalExpression) {
|
|
33838
33844
|
// We do a check here so that we won't be doing unnecessarily call to "lookAhead"
|
|
33839
33845
|
if (token() === 131 /* AsyncKeyword */) {
|
|
33840
33846
|
if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) {
|
|
33841
33847
|
var pos = getNodePos();
|
|
33842
33848
|
var asyncModifier = parseModifiersForArrowFunction();
|
|
33843
33849
|
var expr = parseBinaryExpressionOrHigher(0 /* Lowest */);
|
|
33844
|
-
return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier);
|
|
33850
|
+
return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier, parsingConditionalExpression);
|
|
33845
33851
|
}
|
|
33846
33852
|
}
|
|
33847
33853
|
return undefined;
|
|
@@ -33865,7 +33871,7 @@ var ts;
|
|
|
33865
33871
|
}
|
|
33866
33872
|
return 0 /* False */;
|
|
33867
33873
|
}
|
|
33868
|
-
function parseParenthesizedArrowFunctionExpression(allowAmbiguity) {
|
|
33874
|
+
function parseParenthesizedArrowFunctionExpression(allowAmbiguity, parsingConditionalExpression) {
|
|
33869
33875
|
var pos = getNodePos();
|
|
33870
33876
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
33871
33877
|
var modifiers = parseModifiersForArrowFunction();
|
|
@@ -33891,6 +33897,20 @@ var ts;
|
|
|
33891
33897
|
return undefined;
|
|
33892
33898
|
}
|
|
33893
33899
|
}
|
|
33900
|
+
// Given:
|
|
33901
|
+
// x ? y => ({ y }) : z => ({ z })
|
|
33902
|
+
// We try to parse the body of the first arrow function by looking at:
|
|
33903
|
+
// ({ y }) : z => ({ z })
|
|
33904
|
+
// This is a valid arrow function with "z" as the return type.
|
|
33905
|
+
//
|
|
33906
|
+
// But, if we're in the true side of a conditional expression, this colon
|
|
33907
|
+
// terminates the true side, so cannot be the return type. If we are in the
|
|
33908
|
+
// false side, we may still be within the true side of a parent conditional
|
|
33909
|
+
// expression, so don't allow it to be a return type either.
|
|
33910
|
+
if (parsingConditionalExpression && token() === 58 /* ColonToken */) {
|
|
33911
|
+
ts.Debug.assert(!allowAmbiguity);
|
|
33912
|
+
return undefined;
|
|
33913
|
+
}
|
|
33894
33914
|
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
|
33895
33915
|
if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
|
|
33896
33916
|
return undefined;
|
|
@@ -33924,7 +33944,7 @@ var ts;
|
|
|
33924
33944
|
var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
|
|
33925
33945
|
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
|
33926
33946
|
}
|
|
33927
|
-
function parseArrowFunctionExpressionBody(isAsync) {
|
|
33947
|
+
function parseArrowFunctionExpressionBody(isAsync, parsingConditionalExpression) {
|
|
33928
33948
|
if (token() === 18 /* OpenBraceToken */) {
|
|
33929
33949
|
return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */);
|
|
33930
33950
|
}
|
|
@@ -33952,8 +33972,8 @@ var ts;
|
|
|
33952
33972
|
var savedTopLevel = topLevel;
|
|
33953
33973
|
topLevel = false;
|
|
33954
33974
|
var node = isAsync
|
|
33955
|
-
? doInAwaitContext(parseAssignmentExpressionOrHigher)
|
|
33956
|
-
: doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
|
|
33975
|
+
? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(parsingConditionalExpression); })
|
|
33976
|
+
: doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(parsingConditionalExpression); });
|
|
33957
33977
|
topLevel = savedTopLevel;
|
|
33958
33978
|
return node;
|
|
33959
33979
|
}
|
|
@@ -33966,8 +33986,8 @@ var ts;
|
|
|
33966
33986
|
// Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and
|
|
33967
33987
|
// we do not that for the 'whenFalse' part.
|
|
33968
33988
|
var colonToken;
|
|
33969
|
-
return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
|
|
33970
|
-
? parseAssignmentExpressionOrHigher()
|
|
33989
|
+
return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*parsingConditionalExpression*/ true); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
|
|
33990
|
+
? parseAssignmentExpressionOrHigher(/*parsingConditionalExpression*/ true)
|
|
33971
33991
|
: createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos);
|
|
33972
33992
|
}
|
|
33973
33993
|
function parseBinaryExpressionOrHigher(precedence) {
|
|
@@ -47701,7 +47721,6 @@ var ts;
|
|
|
47701
47721
|
var globalBooleanType;
|
|
47702
47722
|
var globalRegExpType;
|
|
47703
47723
|
var globalThisType;
|
|
47704
|
-
var globalYieldType;
|
|
47705
47724
|
var anyArrayType;
|
|
47706
47725
|
var autoArrayType;
|
|
47707
47726
|
var anyReadonlyArrayType;
|
|
@@ -70794,14 +70813,6 @@ var ts;
|
|
|
70794
70813
|
return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t);
|
|
70795
70814
|
});
|
|
70796
70815
|
}
|
|
70797
|
-
function getYieldTypeArgument(type) {
|
|
70798
|
-
return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalYieldType ? getTypeArguments(type)[0] : undefined;
|
|
70799
|
-
}
|
|
70800
|
-
function getYieldTypeFromContextualType(type) {
|
|
70801
|
-
return mapType(type, function (t) {
|
|
70802
|
-
return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getYieldTypeArgument) : getYieldTypeArgument(t);
|
|
70803
|
-
});
|
|
70804
|
-
}
|
|
70805
70816
|
function getContextualThisParameterType(func) {
|
|
70806
70817
|
if (func.kind === 213 /* ArrowFunction */) {
|
|
70807
70818
|
return undefined;
|
|
@@ -77745,10 +77756,6 @@ var ts;
|
|
|
77745
77756
|
return getIterationTypeOfIterable(use, 1 /* Return */, yieldExpressionType, node.expression)
|
|
77746
77757
|
|| anyType;
|
|
77747
77758
|
}
|
|
77748
|
-
var suggestedReturnType = yieldedType && getYieldTypeFromContextualType(yieldedType);
|
|
77749
|
-
if (suggestedReturnType) {
|
|
77750
|
-
return suggestedReturnType;
|
|
77751
|
-
}
|
|
77752
77759
|
else if (returnType) {
|
|
77753
77760
|
return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync)
|
|
77754
77761
|
|| anyType;
|
|
@@ -85687,7 +85694,6 @@ var ts;
|
|
|
85687
85694
|
globalReadonlyArrayType = getGlobalTypeOrUndefined("ReadonlyArray", /*arity*/ 1) || globalArrayType;
|
|
85688
85695
|
anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType;
|
|
85689
85696
|
globalThisType = getGlobalTypeOrUndefined("ThisType", /*arity*/ 1);
|
|
85690
|
-
globalYieldType = getGlobalTypeOrUndefined("YieldType", /*arity*/ 1);
|
|
85691
85697
|
if (augmentations) {
|
|
85692
85698
|
// merge _nonglobal_ module augmentations.
|
|
85693
85699
|
// this needs to be done after global symbol table is initialized to make sure that all ambient modules are indexed
|