@next-core/brick-utils 2.37.17 → 2.37.18
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/CHANGELOG.md +7 -13
- package/dist/index.bundle.js +345 -234
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +345 -234
- package/dist/index.esm.js.map +1 -1
- package/dist/types/JsonStorage.d.ts +3 -3
- package/package.json +5 -5
package/dist/index.bundle.js
CHANGED
|
@@ -3613,8 +3613,8 @@
|
|
|
3613
3613
|
});
|
|
3614
3614
|
|
|
3615
3615
|
function toESTreeLocation(node) {
|
|
3616
|
-
toUnenumerable(node.loc.start, "index");
|
|
3617
|
-
toUnenumerable(node.loc.end, "index");
|
|
3616
|
+
node.loc.start && toUnenumerable(node.loc.start, "index");
|
|
3617
|
+
node.loc.end && toUnenumerable(node.loc.end, "index");
|
|
3618
3618
|
return node;
|
|
3619
3619
|
}
|
|
3620
3620
|
|
|
@@ -3888,10 +3888,9 @@
|
|
|
3888
3888
|
}
|
|
3889
3889
|
|
|
3890
3890
|
this.toAssignable(value, isLHS);
|
|
3891
|
-
|
|
3891
|
+
} else {
|
|
3892
|
+
super.toAssignable(node, isLHS);
|
|
3892
3893
|
}
|
|
3893
|
-
|
|
3894
|
-
return super.toAssignable(node, isLHS);
|
|
3895
3894
|
}
|
|
3896
3895
|
|
|
3897
3896
|
toAssignableObjectExpressionProp(prop) {
|
|
@@ -3904,11 +3903,7 @@
|
|
|
3904
3903
|
at: prop.key
|
|
3905
3904
|
});
|
|
3906
3905
|
} else {
|
|
3907
|
-
|
|
3908
|
-
args[_key3 - 1] = arguments[_key3];
|
|
3909
|
-
}
|
|
3910
|
-
|
|
3911
|
-
super.toAssignableObjectExpressionProp(prop, ...args);
|
|
3906
|
+
super.toAssignableObjectExpressionProp(...arguments);
|
|
3912
3907
|
}
|
|
3913
3908
|
}
|
|
3914
3909
|
|
|
@@ -4005,6 +4000,11 @@
|
|
|
4005
4000
|
return toESTreeLocation(super.finishNodeAt(node, type, endLoc));
|
|
4006
4001
|
}
|
|
4007
4002
|
|
|
4003
|
+
resetStartLocation(node, start, startLoc) {
|
|
4004
|
+
super.resetStartLocation(node, start, startLoc);
|
|
4005
|
+
toESTreeLocation(node);
|
|
4006
|
+
}
|
|
4007
|
+
|
|
4008
4008
|
resetEndLocation(node) {
|
|
4009
4009
|
var endLoc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.state.lastTokEndLoc;
|
|
4010
4010
|
super.resetEndLocation(node, endLoc);
|
|
@@ -4152,9 +4152,7 @@
|
|
|
4152
4152
|
beforeExpr,
|
|
4153
4153
|
startsExpr
|
|
4154
4154
|
}),
|
|
4155
|
-
braceR: createToken("}",
|
|
4156
|
-
beforeExpr
|
|
4157
|
-
}),
|
|
4155
|
+
braceR: createToken("}"),
|
|
4158
4156
|
braceBarR: createToken("|}"),
|
|
4159
4157
|
parenL: createToken("(", {
|
|
4160
4158
|
beforeExpr,
|
|
@@ -4579,6 +4577,10 @@
|
|
|
4579
4577
|
return tokenBinops[token];
|
|
4580
4578
|
}
|
|
4581
4579
|
|
|
4580
|
+
function tokenIsBinaryOperator(token) {
|
|
4581
|
+
return tokenBinops[token] !== -1;
|
|
4582
|
+
}
|
|
4583
|
+
|
|
4582
4584
|
function tokenIsRightAssociative(token) {
|
|
4583
4585
|
return token === 57;
|
|
4584
4586
|
}
|
|
@@ -5044,6 +5046,7 @@
|
|
|
5044
5046
|
this.hasFlowComment = false;
|
|
5045
5047
|
this.isAmbientContext = false;
|
|
5046
5048
|
this.inAbstractClass = false;
|
|
5049
|
+
this.inDisallowConditionalTypesContext = false;
|
|
5047
5050
|
this.topicContext = {
|
|
5048
5051
|
maxNumOfResolvableTopics: 0,
|
|
5049
5052
|
maxTopicIndex: null
|
|
@@ -7056,7 +7059,7 @@
|
|
|
7056
7059
|
this.parser.raise(toParseError, origin);
|
|
7057
7060
|
}
|
|
7058
7061
|
|
|
7059
|
-
|
|
7062
|
+
recordArrowParemeterBindingError(error, _ref45) {
|
|
7060
7063
|
var {
|
|
7061
7064
|
at: node
|
|
7062
7065
|
} = _ref45;
|
|
@@ -7069,9 +7072,9 @@
|
|
|
7069
7072
|
};
|
|
7070
7073
|
|
|
7071
7074
|
if (scope.isCertainlyParameterDeclaration()) {
|
|
7072
|
-
this.parser.raise(
|
|
7075
|
+
this.parser.raise(error, origin);
|
|
7073
7076
|
} else if (scope.canBeArrowParameterDeclaration()) {
|
|
7074
|
-
scope.recordDeclarationError(
|
|
7077
|
+
scope.recordDeclarationError(error, origin);
|
|
7075
7078
|
} else {
|
|
7076
7079
|
return;
|
|
7077
7080
|
}
|
|
@@ -9522,11 +9525,11 @@
|
|
|
9522
9525
|
toAssignable(node) {
|
|
9523
9526
|
var isLHS = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
9524
9527
|
|
|
9525
|
-
if (node.type === "TypeCastExpression") {
|
|
9526
|
-
|
|
9527
|
-
} else {
|
|
9528
|
-
return super.toAssignable(node, isLHS);
|
|
9528
|
+
if (!isLHS && node.type === "AssignmentExpression" && node.left.type === "TypeCastExpression") {
|
|
9529
|
+
node.left = this.typeCastToParameter(node.left);
|
|
9529
9530
|
}
|
|
9531
|
+
|
|
9532
|
+
super.toAssignable(...arguments);
|
|
9530
9533
|
}
|
|
9531
9534
|
|
|
9532
9535
|
toAssignableList(exprList, trailingCommaLoc, isLHS) {
|
|
@@ -9538,7 +9541,7 @@
|
|
|
9538
9541
|
}
|
|
9539
9542
|
}
|
|
9540
9543
|
|
|
9541
|
-
|
|
9544
|
+
super.toAssignableList(exprList, trailingCommaLoc, isLHS);
|
|
9542
9545
|
}
|
|
9543
9546
|
|
|
9544
9547
|
toReferencedList(exprList, isParenthesizedExpr) {
|
|
@@ -9568,8 +9571,8 @@
|
|
|
9568
9571
|
}
|
|
9569
9572
|
|
|
9570
9573
|
isValidLVal(type) {
|
|
9571
|
-
for (var
|
|
9572
|
-
rest[
|
|
9574
|
+
for (var _len3 = arguments.length, rest = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
9575
|
+
rest[_key3 - 1] = arguments[_key3];
|
|
9573
9576
|
}
|
|
9574
9577
|
|
|
9575
9578
|
return type === "TypeCastExpression" || super.isValidLVal(type, ...rest);
|
|
@@ -10118,7 +10121,8 @@
|
|
|
10118
10121
|
return super.parseSubscript(base, startPos, startLoc, noCalls, subscriptState);
|
|
10119
10122
|
}
|
|
10120
10123
|
|
|
10121
|
-
|
|
10124
|
+
parseNewCallee(node) {
|
|
10125
|
+
super.parseNewCallee(node);
|
|
10122
10126
|
var targs = null;
|
|
10123
10127
|
|
|
10124
10128
|
if (this.shouldParseTypes() && this.match(47)) {
|
|
@@ -10126,7 +10130,6 @@
|
|
|
10126
10130
|
}
|
|
10127
10131
|
|
|
10128
10132
|
node.typeArguments = targs;
|
|
10129
|
-
super.parseNewArguments(node);
|
|
10130
10133
|
}
|
|
10131
10134
|
|
|
10132
10135
|
parseAsyncArrowWithTypeParameters(startPos, startLoc) {
|
|
@@ -11199,6 +11202,7 @@
|
|
|
11199
11202
|
this.next();
|
|
11200
11203
|
node.expression = this.parseExpression();
|
|
11201
11204
|
this.setContext(types.j_oTag);
|
|
11205
|
+
this.state.canStartJSXElement = true;
|
|
11202
11206
|
this.expect(8);
|
|
11203
11207
|
return this.finishNode(node, "JSXSpreadChild");
|
|
11204
11208
|
}
|
|
@@ -11212,6 +11216,7 @@
|
|
|
11212
11216
|
}
|
|
11213
11217
|
|
|
11214
11218
|
this.setContext(previousContext);
|
|
11219
|
+
this.state.canStartJSXElement = true;
|
|
11215
11220
|
this.expect(8);
|
|
11216
11221
|
return this.finishNode(node, "JSXExpressionContainer");
|
|
11217
11222
|
}
|
|
@@ -11225,6 +11230,7 @@
|
|
|
11225
11230
|
this.expect(21);
|
|
11226
11231
|
node.argument = this.parseMaybeAssignAllowIn();
|
|
11227
11232
|
this.setContext(types.j_oTag);
|
|
11233
|
+
this.state.canStartJSXElement = true;
|
|
11228
11234
|
this.expect(8);
|
|
11229
11235
|
return this.finishNode(node, "JSXSpreadAttribute");
|
|
11230
11236
|
}
|
|
@@ -11237,8 +11243,7 @@
|
|
|
11237
11243
|
jsxParseOpeningElementAt(startPos, startLoc) {
|
|
11238
11244
|
var node = this.startNodeAt(startPos, startLoc);
|
|
11239
11245
|
|
|
11240
|
-
if (this.
|
|
11241
|
-
this.expect(139);
|
|
11246
|
+
if (this.eat(139)) {
|
|
11242
11247
|
return this.finishNode(node, "JSXOpeningFragment");
|
|
11243
11248
|
}
|
|
11244
11249
|
|
|
@@ -11262,8 +11267,7 @@
|
|
|
11262
11267
|
jsxParseClosingElementAt(startPos, startLoc) {
|
|
11263
11268
|
var node = this.startNodeAt(startPos, startLoc);
|
|
11264
11269
|
|
|
11265
|
-
if (this.
|
|
11266
|
-
this.expect(139);
|
|
11270
|
+
if (this.eat(139)) {
|
|
11267
11271
|
return this.finishNode(node, "JSXClosingFragment");
|
|
11268
11272
|
}
|
|
11269
11273
|
|
|
@@ -11544,6 +11548,10 @@
|
|
|
11544
11548
|
}
|
|
11545
11549
|
}
|
|
11546
11550
|
|
|
11551
|
+
function tsTokenCanStartExpression(token) {
|
|
11552
|
+
return tokenCanStartExpression(token) || tokenIsBinaryOperator(token);
|
|
11553
|
+
}
|
|
11554
|
+
|
|
11547
11555
|
var TSErrors = ParseErrorEnum(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral__default["default"](["typescript"])))(_ => ({
|
|
11548
11556
|
AbstractMethodHasImplementation: _(_ref71 => {
|
|
11549
11557
|
var {
|
|
@@ -11619,10 +11627,22 @@
|
|
|
11619
11627
|
} = _ref80;
|
|
11620
11628
|
return "'".concat(modifier, "' modifier cannot appear on a type member.");
|
|
11621
11629
|
}),
|
|
11622
|
-
|
|
11630
|
+
InvalidModifierOnTypeParameter: _(_ref81 => {
|
|
11623
11631
|
var {
|
|
11624
|
-
|
|
11632
|
+
modifier
|
|
11625
11633
|
} = _ref81;
|
|
11634
|
+
return "'".concat(modifier, "' modifier cannot appear on a type parameter.");
|
|
11635
|
+
}),
|
|
11636
|
+
InvalidModifierOnTypeParameterPositions: _(_ref82 => {
|
|
11637
|
+
var {
|
|
11638
|
+
modifier
|
|
11639
|
+
} = _ref82;
|
|
11640
|
+
return "'".concat(modifier, "' modifier can only appear on a type parameter of a class, interface or type alias.");
|
|
11641
|
+
}),
|
|
11642
|
+
InvalidModifiersOrder: _(_ref83 => {
|
|
11643
|
+
var {
|
|
11644
|
+
orderedModifiers
|
|
11645
|
+
} = _ref83;
|
|
11626
11646
|
return "'".concat(orderedModifiers[0], "' modifier must precede '").concat(orderedModifiers[1], "' modifier.");
|
|
11627
11647
|
}),
|
|
11628
11648
|
InvalidTupleMemberLabel: _("Tuple members must be labeled with a simple identifier."),
|
|
@@ -11634,10 +11654,10 @@
|
|
|
11634
11654
|
OverrideNotInSubClass: _("This member cannot have an 'override' modifier because its containing class does not extend another class."),
|
|
11635
11655
|
PatternIsOptional: _("A binding pattern parameter cannot be optional in an implementation signature."),
|
|
11636
11656
|
PrivateElementHasAbstract: _("Private elements cannot have the 'abstract' modifier."),
|
|
11637
|
-
PrivateElementHasAccessibility: _(
|
|
11657
|
+
PrivateElementHasAccessibility: _(_ref84 => {
|
|
11638
11658
|
var {
|
|
11639
11659
|
modifier
|
|
11640
|
-
} =
|
|
11660
|
+
} = _ref84;
|
|
11641
11661
|
return "Private elements cannot have an accessibility modifier ('".concat(modifier, "').");
|
|
11642
11662
|
}),
|
|
11643
11663
|
ReadonlyForMethodSignature: _("'readonly' modifier can only appear on a property declaration or index signature."),
|
|
@@ -11646,10 +11666,10 @@
|
|
|
11646
11666
|
SetAccesorCannotHaveOptionalParameter: _("A 'set' accessor cannot have an optional parameter."),
|
|
11647
11667
|
SetAccesorCannotHaveRestParameter: _("A 'set' accessor cannot have rest parameter."),
|
|
11648
11668
|
SetAccesorCannotHaveReturnType: _("A 'set' accessor cannot have a return type annotation."),
|
|
11649
|
-
SingleTypeParameterWithoutTrailingComma: _(
|
|
11669
|
+
SingleTypeParameterWithoutTrailingComma: _(_ref85 => {
|
|
11650
11670
|
var {
|
|
11651
11671
|
typeParameterName
|
|
11652
|
-
} =
|
|
11672
|
+
} = _ref85;
|
|
11653
11673
|
return "Single type parameter ".concat(typeParameterName, " should have a trailing comma. Example usage: <").concat(typeParameterName, ",>.");
|
|
11654
11674
|
}),
|
|
11655
11675
|
StaticBlockCannotHaveModifier: _("Static class blocks cannot have any modifier."),
|
|
@@ -11663,10 +11683,10 @@
|
|
|
11663
11683
|
UnexpectedTypeCastInParameter: _("Unexpected type cast in parameter position."),
|
|
11664
11684
|
UnsupportedImportTypeArgument: _("Argument in a type import must be a string literal."),
|
|
11665
11685
|
UnsupportedParameterPropertyKind: _("A parameter property may not be declared using a binding pattern."),
|
|
11666
|
-
UnsupportedSignatureParameterKind: _(
|
|
11686
|
+
UnsupportedSignatureParameterKind: _(_ref86 => {
|
|
11667
11687
|
var {
|
|
11668
11688
|
type
|
|
11669
|
-
} =
|
|
11689
|
+
} = _ref86;
|
|
11670
11690
|
return "Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ".concat(type, ".");
|
|
11671
11691
|
})
|
|
11672
11692
|
}));
|
|
@@ -11712,6 +11732,10 @@
|
|
|
11712
11732
|
return modifier === "private" || modifier === "public" || modifier === "protected";
|
|
11713
11733
|
}
|
|
11714
11734
|
|
|
11735
|
+
function tsIsVarianceAnnotations(modifier) {
|
|
11736
|
+
return modifier === "in" || modifier === "out";
|
|
11737
|
+
}
|
|
11738
|
+
|
|
11715
11739
|
var typescript = superClass => class extends superClass {
|
|
11716
11740
|
getScopeHandler() {
|
|
11717
11741
|
return TypeScriptScopeHandler;
|
|
@@ -11731,7 +11755,7 @@
|
|
|
11731
11755
|
}
|
|
11732
11756
|
|
|
11733
11757
|
tsParseModifier(allowedModifiers, stopOnStartOfClassStaticBlock) {
|
|
11734
|
-
if (!tokenIsIdentifier(this.state.type)) {
|
|
11758
|
+
if (!tokenIsIdentifier(this.state.type) && this.state.type !== 58) {
|
|
11735
11759
|
return undefined;
|
|
11736
11760
|
}
|
|
11737
11761
|
|
|
@@ -11750,13 +11774,14 @@
|
|
|
11750
11774
|
return undefined;
|
|
11751
11775
|
}
|
|
11752
11776
|
|
|
11753
|
-
tsParseModifiers(
|
|
11777
|
+
tsParseModifiers(_ref87) {
|
|
11754
11778
|
var {
|
|
11755
11779
|
modified,
|
|
11756
11780
|
allowedModifiers,
|
|
11757
11781
|
disallowedModifiers,
|
|
11758
|
-
stopOnStartOfClassStaticBlock
|
|
11759
|
-
|
|
11782
|
+
stopOnStartOfClassStaticBlock,
|
|
11783
|
+
errorTemplate = TSErrors.InvalidModifierOnTypeMember
|
|
11784
|
+
} = _ref87;
|
|
11760
11785
|
|
|
11761
11786
|
var enforceOrder = (loc, modifier, before, after) => {
|
|
11762
11787
|
if (modifier === before && modified[after]) {
|
|
@@ -11795,6 +11820,16 @@
|
|
|
11795
11820
|
enforceOrder(startLoc, modifier, modifier, "readonly");
|
|
11796
11821
|
modified.accessibility = modifier;
|
|
11797
11822
|
}
|
|
11823
|
+
} else if (tsIsVarianceAnnotations(modifier)) {
|
|
11824
|
+
if (modified[modifier]) {
|
|
11825
|
+
this.raise(TSErrors.DuplicateModifier, {
|
|
11826
|
+
at: startLoc,
|
|
11827
|
+
modifier
|
|
11828
|
+
});
|
|
11829
|
+
}
|
|
11830
|
+
|
|
11831
|
+
modified[modifier] = true;
|
|
11832
|
+
enforceOrder(startLoc, modifier, "in", "out");
|
|
11798
11833
|
} else {
|
|
11799
11834
|
if (Object.hasOwnProperty.call(modified, modifier)) {
|
|
11800
11835
|
this.raise(TSErrors.DuplicateModifier, {
|
|
@@ -11814,7 +11849,7 @@
|
|
|
11814
11849
|
}
|
|
11815
11850
|
|
|
11816
11851
|
if (disallowedModifiers != null && disallowedModifiers.includes(modifier)) {
|
|
11817
|
-
this.raise(
|
|
11852
|
+
this.raise(errorTemplate, {
|
|
11818
11853
|
at: startLoc,
|
|
11819
11854
|
modifier
|
|
11820
11855
|
});
|
|
@@ -11991,24 +12026,48 @@
|
|
|
11991
12026
|
node.exprName = this.tsParseEntityName();
|
|
11992
12027
|
}
|
|
11993
12028
|
|
|
12029
|
+
if (!this.hasPrecedingLineBreak() && this.match(47)) {
|
|
12030
|
+
node.typeParameters = this.tsParseTypeArguments();
|
|
12031
|
+
}
|
|
12032
|
+
|
|
11994
12033
|
return this.finishNode(node, "TSTypeQuery");
|
|
11995
12034
|
}
|
|
11996
12035
|
|
|
12036
|
+
tsParseInOutModifiers(node) {
|
|
12037
|
+
this.tsParseModifiers({
|
|
12038
|
+
modified: node,
|
|
12039
|
+
allowedModifiers: ["in", "out"],
|
|
12040
|
+
disallowedModifiers: ["public", "private", "protected", "readonly", "declare", "abstract", "override"],
|
|
12041
|
+
errorTemplate: TSErrors.InvalidModifierOnTypeParameter
|
|
12042
|
+
});
|
|
12043
|
+
}
|
|
12044
|
+
|
|
12045
|
+
tsParseNoneModifiers(node) {
|
|
12046
|
+
this.tsParseModifiers({
|
|
12047
|
+
modified: node,
|
|
12048
|
+
allowedModifiers: [],
|
|
12049
|
+
disallowedModifiers: ["in", "out"],
|
|
12050
|
+
errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions
|
|
12051
|
+
});
|
|
12052
|
+
}
|
|
12053
|
+
|
|
11997
12054
|
tsParseTypeParameter() {
|
|
12055
|
+
var parseModifiers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.tsParseNoneModifiers.bind(this);
|
|
11998
12056
|
var node = this.startNode();
|
|
12057
|
+
parseModifiers(node);
|
|
11999
12058
|
node.name = this.tsParseTypeParameterName();
|
|
12000
12059
|
node.constraint = this.tsEatThenParseType(81);
|
|
12001
12060
|
node.default = this.tsEatThenParseType(29);
|
|
12002
12061
|
return this.finishNode(node, "TSTypeParameter");
|
|
12003
12062
|
}
|
|
12004
12063
|
|
|
12005
|
-
tsTryParseTypeParameters() {
|
|
12064
|
+
tsTryParseTypeParameters(parseModifiers) {
|
|
12006
12065
|
if (this.match(47)) {
|
|
12007
|
-
return this.tsParseTypeParameters();
|
|
12066
|
+
return this.tsParseTypeParameters(parseModifiers);
|
|
12008
12067
|
}
|
|
12009
12068
|
}
|
|
12010
12069
|
|
|
12011
|
-
tsParseTypeParameters() {
|
|
12070
|
+
tsParseTypeParameters(parseModifiers) {
|
|
12012
12071
|
var node = this.startNode();
|
|
12013
12072
|
|
|
12014
12073
|
if (this.match(47) || this.match(138)) {
|
|
@@ -12020,7 +12079,7 @@
|
|
|
12020
12079
|
var refTrailingCommaPos = {
|
|
12021
12080
|
value: -1
|
|
12022
12081
|
};
|
|
12023
|
-
node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this), false, true, refTrailingCommaPos);
|
|
12082
|
+
node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this, parseModifiers), false, true, refTrailingCommaPos);
|
|
12024
12083
|
|
|
12025
12084
|
if (node.params.length === 0) {
|
|
12026
12085
|
this.raise(TSErrors.EmptyTypeParameters, {
|
|
@@ -12411,7 +12470,7 @@
|
|
|
12411
12470
|
this.next();
|
|
12412
12471
|
}
|
|
12413
12472
|
|
|
12414
|
-
this.tsFillSignature(19, node);
|
|
12473
|
+
this.tsInAllowConditionalTypesContext(() => this.tsFillSignature(19, node));
|
|
12415
12474
|
return this.finishNode(node, type);
|
|
12416
12475
|
}
|
|
12417
12476
|
|
|
@@ -12580,13 +12639,24 @@
|
|
|
12580
12639
|
this.expectContextual(112);
|
|
12581
12640
|
var typeParameter = this.startNode();
|
|
12582
12641
|
typeParameter.name = this.tsParseTypeParameterName();
|
|
12642
|
+
typeParameter.constraint = this.tsTryParse(() => this.tsParseConstraintForInferType());
|
|
12583
12643
|
node.typeParameter = this.finishNode(typeParameter, "TSTypeParameter");
|
|
12584
12644
|
return this.finishNode(node, "TSInferType");
|
|
12585
12645
|
}
|
|
12586
12646
|
|
|
12647
|
+
tsParseConstraintForInferType() {
|
|
12648
|
+
if (this.eat(81)) {
|
|
12649
|
+
var constraint = this.tsInDisallowConditionalTypesContext(() => this.tsParseType());
|
|
12650
|
+
|
|
12651
|
+
if (this.state.inDisallowConditionalTypesContext || !this.match(17)) {
|
|
12652
|
+
return constraint;
|
|
12653
|
+
}
|
|
12654
|
+
}
|
|
12655
|
+
}
|
|
12656
|
+
|
|
12587
12657
|
tsParseTypeOperatorOrHigher() {
|
|
12588
12658
|
var isTypeOperator = tokenIsTSTypeOperator(this.state.type) && !this.state.containsEsc;
|
|
12589
|
-
return isTypeOperator ? this.tsParseTypeOperator() : this.isContextual(112) ? this.tsParseInferType() : this.tsParseArrayTypeOrHigher();
|
|
12659
|
+
return isTypeOperator ? this.tsParseTypeOperator() : this.isContextual(112) ? this.tsParseInferType() : this.tsInAllowConditionalTypesContext(() => this.tsParseArrayTypeOrHigher());
|
|
12590
12660
|
}
|
|
12591
12661
|
|
|
12592
12662
|
tsParseUnionOrIntersectionType(kind, parseConstituentType, operator) {
|
|
@@ -12788,17 +12858,17 @@
|
|
|
12788
12858
|
assert(this.state.inType);
|
|
12789
12859
|
var type = this.tsParseNonConditionalType();
|
|
12790
12860
|
|
|
12791
|
-
if (this.hasPrecedingLineBreak() || !this.eat(81)) {
|
|
12861
|
+
if (this.state.inDisallowConditionalTypesContext || this.hasPrecedingLineBreak() || !this.eat(81)) {
|
|
12792
12862
|
return type;
|
|
12793
12863
|
}
|
|
12794
12864
|
|
|
12795
12865
|
var node = this.startNodeAtNode(type);
|
|
12796
12866
|
node.checkType = type;
|
|
12797
|
-
node.extendsType = this.tsParseNonConditionalType();
|
|
12867
|
+
node.extendsType = this.tsInDisallowConditionalTypesContext(() => this.tsParseNonConditionalType());
|
|
12798
12868
|
this.expect(17);
|
|
12799
|
-
node.trueType = this.tsParseType();
|
|
12869
|
+
node.trueType = this.tsInAllowConditionalTypesContext(() => this.tsParseType());
|
|
12800
12870
|
this.expect(14);
|
|
12801
|
-
node.falseType = this.tsParseType();
|
|
12871
|
+
node.falseType = this.tsInAllowConditionalTypesContext(() => this.tsParseType());
|
|
12802
12872
|
return this.finishNode(node, "TSConditionalType");
|
|
12803
12873
|
}
|
|
12804
12874
|
|
|
@@ -12839,7 +12909,16 @@
|
|
|
12839
12909
|
|
|
12840
12910
|
tsParseHeritageClause(token) {
|
|
12841
12911
|
var originalStartLoc = this.state.startLoc;
|
|
12842
|
-
var delimitedList = this.tsParseDelimitedList("HeritageClauseElement",
|
|
12912
|
+
var delimitedList = this.tsParseDelimitedList("HeritageClauseElement", () => {
|
|
12913
|
+
var node = this.startNode();
|
|
12914
|
+
node.expression = this.tsParseEntityName();
|
|
12915
|
+
|
|
12916
|
+
if (this.match(47)) {
|
|
12917
|
+
node.typeParameters = this.tsParseTypeArguments();
|
|
12918
|
+
}
|
|
12919
|
+
|
|
12920
|
+
return this.finishNode(node, "TSExpressionWithTypeArguments");
|
|
12921
|
+
});
|
|
12843
12922
|
|
|
12844
12923
|
if (!delimitedList.length) {
|
|
12845
12924
|
this.raise(TSErrors.EmptyHeritageClauseType, {
|
|
@@ -12851,17 +12930,6 @@
|
|
|
12851
12930
|
return delimitedList;
|
|
12852
12931
|
}
|
|
12853
12932
|
|
|
12854
|
-
tsParseExpressionWithTypeArguments() {
|
|
12855
|
-
var node = this.startNode();
|
|
12856
|
-
node.expression = this.tsParseEntityName();
|
|
12857
|
-
|
|
12858
|
-
if (this.match(47)) {
|
|
12859
|
-
node.typeParameters = this.tsParseTypeArguments();
|
|
12860
|
-
}
|
|
12861
|
-
|
|
12862
|
-
return this.finishNode(node, "TSExpressionWithTypeArguments");
|
|
12863
|
-
}
|
|
12864
|
-
|
|
12865
12933
|
tsParseInterfaceDeclaration(node) {
|
|
12866
12934
|
var properties = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
12867
12935
|
if (this.hasFollowingLineBreak()) return null;
|
|
@@ -12878,7 +12946,7 @@
|
|
|
12878
12946
|
});
|
|
12879
12947
|
}
|
|
12880
12948
|
|
|
12881
|
-
node.typeParameters = this.tsTryParseTypeParameters();
|
|
12949
|
+
node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers.bind(this));
|
|
12882
12950
|
|
|
12883
12951
|
if (this.eat(81)) {
|
|
12884
12952
|
node.extends = this.tsParseHeritageClause("extends");
|
|
@@ -12894,7 +12962,7 @@
|
|
|
12894
12962
|
node.id = this.parseIdentifier();
|
|
12895
12963
|
this.checkIdentifier(node.id, BIND_TS_TYPE);
|
|
12896
12964
|
node.typeAnnotation = this.tsInType(() => {
|
|
12897
|
-
node.typeParameters = this.tsTryParseTypeParameters();
|
|
12965
|
+
node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers.bind(this));
|
|
12898
12966
|
this.expect(29);
|
|
12899
12967
|
|
|
12900
12968
|
if (this.isContextual(111) && this.lookahead().type !== 16) {
|
|
@@ -12932,6 +13000,28 @@
|
|
|
12932
13000
|
}
|
|
12933
13001
|
}
|
|
12934
13002
|
|
|
13003
|
+
tsInDisallowConditionalTypesContext(cb) {
|
|
13004
|
+
var oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext;
|
|
13005
|
+
this.state.inDisallowConditionalTypesContext = true;
|
|
13006
|
+
|
|
13007
|
+
try {
|
|
13008
|
+
return cb();
|
|
13009
|
+
} finally {
|
|
13010
|
+
this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext;
|
|
13011
|
+
}
|
|
13012
|
+
}
|
|
13013
|
+
|
|
13014
|
+
tsInAllowConditionalTypesContext(cb) {
|
|
13015
|
+
var oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext;
|
|
13016
|
+
this.state.inDisallowConditionalTypesContext = false;
|
|
13017
|
+
|
|
13018
|
+
try {
|
|
13019
|
+
return cb();
|
|
13020
|
+
} finally {
|
|
13021
|
+
this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext;
|
|
13022
|
+
}
|
|
13023
|
+
}
|
|
13024
|
+
|
|
12935
13025
|
tsEatThenParseType(token) {
|
|
12936
13026
|
return !this.match(token) ? undefined : this.tsNextThenParseType();
|
|
12937
13027
|
}
|
|
@@ -13451,35 +13541,44 @@
|
|
|
13451
13541
|
}
|
|
13452
13542
|
}
|
|
13453
13543
|
|
|
13454
|
-
var node = this.startNodeAt(startPos, startLoc);
|
|
13455
|
-
node.callee = base;
|
|
13456
13544
|
var typeArguments = this.tsParseTypeArgumentsInExpression();
|
|
13545
|
+
if (!typeArguments) throw this.unexpected();
|
|
13457
13546
|
|
|
13458
|
-
if (
|
|
13459
|
-
|
|
13460
|
-
|
|
13461
|
-
|
|
13462
|
-
}
|
|
13547
|
+
if (isOptionalCall && !this.match(10)) {
|
|
13548
|
+
missingParenErrorLoc = this.state.curPosition();
|
|
13549
|
+
throw this.unexpected();
|
|
13550
|
+
}
|
|
13463
13551
|
|
|
13464
|
-
|
|
13465
|
-
|
|
13466
|
-
this.tsCheckForInvalidTypeCasts(node.arguments);
|
|
13467
|
-
node.typeParameters = typeArguments;
|
|
13552
|
+
if (tokenIsTemplate(this.state.type)) {
|
|
13553
|
+
var _result = this.parseTaggedTemplateExpression(base, startPos, startLoc, state);
|
|
13468
13554
|
|
|
13469
|
-
|
|
13470
|
-
|
|
13471
|
-
|
|
13555
|
+
_result.typeParameters = typeArguments;
|
|
13556
|
+
return _result;
|
|
13557
|
+
}
|
|
13558
|
+
|
|
13559
|
+
if (!noCalls && this.eat(10)) {
|
|
13560
|
+
var _node9 = this.startNodeAt(startPos, startLoc);
|
|
13472
13561
|
|
|
13473
|
-
|
|
13474
|
-
|
|
13475
|
-
|
|
13562
|
+
_node9.callee = base;
|
|
13563
|
+
_node9.arguments = this.parseCallExpressionArguments(11, false);
|
|
13564
|
+
this.tsCheckForInvalidTypeCasts(_node9.arguments);
|
|
13565
|
+
_node9.typeParameters = typeArguments;
|
|
13476
13566
|
|
|
13477
|
-
|
|
13478
|
-
|
|
13567
|
+
if (state.optionalChainMember) {
|
|
13568
|
+
_node9.optional = isOptionalCall;
|
|
13479
13569
|
}
|
|
13570
|
+
|
|
13571
|
+
return this.finishCallExpression(_node9, state.optionalChainMember);
|
|
13480
13572
|
}
|
|
13481
13573
|
|
|
13482
|
-
this.
|
|
13574
|
+
if (tsTokenCanStartExpression(this.state.type) && this.state.type !== 10) {
|
|
13575
|
+
throw this.unexpected();
|
|
13576
|
+
}
|
|
13577
|
+
|
|
13578
|
+
var node = this.startNodeAt(startPos, startLoc);
|
|
13579
|
+
node.expression = base;
|
|
13580
|
+
node.typeParameters = typeArguments;
|
|
13581
|
+
return this.finishNode(node, "TSInstantiationExpression");
|
|
13483
13582
|
});
|
|
13484
13583
|
|
|
13485
13584
|
if (missingParenErrorLoc) {
|
|
@@ -13492,20 +13591,18 @@
|
|
|
13492
13591
|
return super.parseSubscript(base, startPos, startLoc, noCalls, state);
|
|
13493
13592
|
}
|
|
13494
13593
|
|
|
13495
|
-
|
|
13496
|
-
|
|
13497
|
-
var typeParameters = this.tsTryParseAndCatch(() => {
|
|
13498
|
-
var args = this.tsParseTypeArgumentsInExpression();
|
|
13499
|
-
if (!this.match(10)) this.unexpected();
|
|
13500
|
-
return args;
|
|
13501
|
-
});
|
|
13594
|
+
parseNewCallee(node) {
|
|
13595
|
+
var _callee$extra;
|
|
13502
13596
|
|
|
13503
|
-
|
|
13504
|
-
|
|
13505
|
-
|
|
13506
|
-
}
|
|
13597
|
+
super.parseNewCallee(node);
|
|
13598
|
+
var {
|
|
13599
|
+
callee
|
|
13600
|
+
} = node;
|
|
13507
13601
|
|
|
13508
|
-
|
|
13602
|
+
if (callee.type === "TSInstantiationExpression" && !((_callee$extra = callee.extra) != null && _callee$extra.parenthesized)) {
|
|
13603
|
+
node.typeParameters = callee.typeParameters;
|
|
13604
|
+
node.callee = callee.expression;
|
|
13605
|
+
}
|
|
13509
13606
|
}
|
|
13510
13607
|
|
|
13511
13608
|
parseExprOp(left, leftStartPos, leftStartLoc, minPrec) {
|
|
@@ -13693,7 +13790,9 @@
|
|
|
13693
13790
|
this.tsParseModifiers({
|
|
13694
13791
|
modified: member,
|
|
13695
13792
|
allowedModifiers: modifiers,
|
|
13696
|
-
|
|
13793
|
+
disallowedModifiers: ["in", "out"],
|
|
13794
|
+
stopOnStartOfClassStaticBlock: true,
|
|
13795
|
+
errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions
|
|
13697
13796
|
});
|
|
13698
13797
|
|
|
13699
13798
|
var callParseClassMemberWithIsStatic = () => {
|
|
@@ -13872,7 +13971,7 @@
|
|
|
13872
13971
|
}
|
|
13873
13972
|
|
|
13874
13973
|
super.parseClassId(node, isStatement, optionalId, node.declare ? BIND_TS_AMBIENT : BIND_CLASS);
|
|
13875
|
-
var typeParameters = this.tsTryParseTypeParameters();
|
|
13974
|
+
var typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers.bind(this));
|
|
13876
13975
|
if (typeParameters) node.typeParameters = typeParameters;
|
|
13877
13976
|
}
|
|
13878
13977
|
|
|
@@ -13978,8 +14077,8 @@
|
|
|
13978
14077
|
var typeParameters = this.tsTryParseTypeParameters();
|
|
13979
14078
|
if (typeParameters) prop.typeParameters = typeParameters;
|
|
13980
14079
|
|
|
13981
|
-
for (var
|
|
13982
|
-
args[
|
|
14080
|
+
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
14081
|
+
args[_key4 - 1] = arguments[_key4];
|
|
13983
14082
|
}
|
|
13984
14083
|
|
|
13985
14084
|
super.parseObjPropValue(prop, ...args);
|
|
@@ -14015,8 +14114,8 @@
|
|
|
14015
14114
|
}
|
|
14016
14115
|
|
|
14017
14116
|
parseMaybeAssign() {
|
|
14018
|
-
for (var
|
|
14019
|
-
args[
|
|
14117
|
+
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
14118
|
+
args[_key5] = arguments[_key5];
|
|
14020
14119
|
}
|
|
14021
14120
|
|
|
14022
14121
|
var _jsx, _jsx2, _typeCast, _jsx3, _typeCast2, _jsx4, _typeCast3;
|
|
@@ -14043,10 +14142,10 @@
|
|
|
14043
14142
|
return super.parseMaybeAssign(...args);
|
|
14044
14143
|
}
|
|
14045
14144
|
|
|
14145
|
+
if (!state || state === this.state) state = this.state.clone();
|
|
14046
14146
|
var typeParameters;
|
|
14047
|
-
state = state || this.state.clone();
|
|
14048
14147
|
var arrow = this.tryParse(abort => {
|
|
14049
|
-
var _expr$extra, _typeParameters
|
|
14148
|
+
var _expr$extra, _typeParameters;
|
|
14050
14149
|
|
|
14051
14150
|
typeParameters = this.tsParseTypeParameters();
|
|
14052
14151
|
var expr = super.parseMaybeAssign(...args);
|
|
@@ -14060,12 +14159,6 @@
|
|
|
14060
14159
|
}
|
|
14061
14160
|
|
|
14062
14161
|
expr.typeParameters = typeParameters;
|
|
14063
|
-
|
|
14064
|
-
if (this.hasPlugin("jsx") && expr.typeParameters.params.length === 1 && !((_expr$typeParameters$ = expr.typeParameters.extra) != null && _expr$typeParameters$.trailingComma)) {
|
|
14065
|
-
var parameter = expr.typeParameters.params[0];
|
|
14066
|
-
if (!parameter.constraint) ;
|
|
14067
|
-
}
|
|
14068
|
-
|
|
14069
14162
|
return expr;
|
|
14070
14163
|
}, state);
|
|
14071
14164
|
|
|
@@ -14172,23 +14265,33 @@
|
|
|
14172
14265
|
var isLHS = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
14173
14266
|
|
|
14174
14267
|
switch (node.type) {
|
|
14175
|
-
case "TSTypeCastExpression":
|
|
14176
|
-
return super.toAssignable(this.typeCastToParameter(node), isLHS);
|
|
14177
|
-
|
|
14178
|
-
case "TSParameterProperty":
|
|
14179
|
-
return super.toAssignable(node, isLHS);
|
|
14180
|
-
|
|
14181
14268
|
case "ParenthesizedExpression":
|
|
14182
|
-
|
|
14269
|
+
this.toAssignableParenthesizedExpression(node, isLHS);
|
|
14270
|
+
break;
|
|
14183
14271
|
|
|
14184
14272
|
case "TSAsExpression":
|
|
14185
14273
|
case "TSNonNullExpression":
|
|
14186
14274
|
case "TSTypeAssertion":
|
|
14187
|
-
|
|
14188
|
-
|
|
14275
|
+
if (isLHS) {
|
|
14276
|
+
this.expressionScope.recordArrowParemeterBindingError(TSErrors.UnexpectedTypeCastInParameter, {
|
|
14277
|
+
at: node
|
|
14278
|
+
});
|
|
14279
|
+
} else {
|
|
14280
|
+
this.raise(TSErrors.UnexpectedTypeCastInParameter, {
|
|
14281
|
+
at: node
|
|
14282
|
+
});
|
|
14283
|
+
}
|
|
14284
|
+
|
|
14285
|
+
this.toAssignable(node.expression, isLHS);
|
|
14286
|
+
break;
|
|
14287
|
+
|
|
14288
|
+
case "AssignmentExpression":
|
|
14289
|
+
if (!isLHS && node.left.type === "TSTypeCastExpression") {
|
|
14290
|
+
node.left = this.typeCastToParameter(node.left);
|
|
14291
|
+
}
|
|
14189
14292
|
|
|
14190
14293
|
default:
|
|
14191
|
-
|
|
14294
|
+
super.toAssignable(node, isLHS);
|
|
14192
14295
|
}
|
|
14193
14296
|
}
|
|
14194
14297
|
|
|
@@ -14198,22 +14301,35 @@
|
|
|
14198
14301
|
case "TSNonNullExpression":
|
|
14199
14302
|
case "TSTypeAssertion":
|
|
14200
14303
|
case "ParenthesizedExpression":
|
|
14201
|
-
|
|
14202
|
-
|
|
14304
|
+
this.toAssignable(node.expression, isLHS);
|
|
14305
|
+
break;
|
|
14306
|
+
|
|
14307
|
+
default:
|
|
14308
|
+
super.toAssignable(node, isLHS);
|
|
14309
|
+
}
|
|
14310
|
+
}
|
|
14311
|
+
|
|
14312
|
+
checkToRestConversion(node, allowPattern) {
|
|
14313
|
+
switch (node.type) {
|
|
14314
|
+
case "TSAsExpression":
|
|
14315
|
+
case "TSTypeAssertion":
|
|
14316
|
+
case "TSNonNullExpression":
|
|
14317
|
+
this.checkToRestConversion(node.expression, false);
|
|
14318
|
+
break;
|
|
14203
14319
|
|
|
14204
14320
|
default:
|
|
14205
|
-
|
|
14321
|
+
super.checkToRestConversion(node, allowPattern);
|
|
14206
14322
|
}
|
|
14207
14323
|
}
|
|
14208
14324
|
|
|
14209
|
-
isValidLVal(type,
|
|
14325
|
+
isValidLVal(type, isUnparenthesizedInAssign, binding) {
|
|
14210
14326
|
return getOwn$1({
|
|
14211
14327
|
TSTypeCastExpression: true,
|
|
14212
14328
|
TSParameterProperty: "parameter",
|
|
14213
14329
|
TSNonNullExpression: "expression",
|
|
14214
|
-
TSAsExpression: (binding !== BIND_NONE ||
|
|
14215
|
-
TSTypeAssertion: (binding !== BIND_NONE ||
|
|
14216
|
-
}, type) || super.isValidLVal(type,
|
|
14330
|
+
TSAsExpression: (binding !== BIND_NONE || !isUnparenthesizedInAssign) && ["expression", true],
|
|
14331
|
+
TSTypeAssertion: (binding !== BIND_NONE || !isUnparenthesizedInAssign) && ["expression", true]
|
|
14332
|
+
}, type) || super.isValidLVal(type, isUnparenthesizedInAssign, binding);
|
|
14217
14333
|
}
|
|
14218
14334
|
|
|
14219
14335
|
parseBindingAtom() {
|
|
@@ -14316,28 +14432,13 @@
|
|
|
14316
14432
|
toAssignableList(exprList) {
|
|
14317
14433
|
for (var i = 0; i < exprList.length; i++) {
|
|
14318
14434
|
var expr = exprList[i];
|
|
14319
|
-
if (!expr) continue;
|
|
14320
14435
|
|
|
14321
|
-
|
|
14322
|
-
|
|
14323
|
-
exprList[i] = this.typeCastToParameter(expr);
|
|
14324
|
-
break;
|
|
14325
|
-
|
|
14326
|
-
case "TSAsExpression":
|
|
14327
|
-
case "TSTypeAssertion":
|
|
14328
|
-
if (!this.state.maybeInArrowParameters) {
|
|
14329
|
-
exprList[i] = this.typeCastToParameter(expr);
|
|
14330
|
-
} else {
|
|
14331
|
-
this.raise(TSErrors.UnexpectedTypeCastInParameter, {
|
|
14332
|
-
at: expr
|
|
14333
|
-
});
|
|
14334
|
-
}
|
|
14335
|
-
|
|
14336
|
-
break;
|
|
14436
|
+
if ((expr == null ? void 0 : expr.type) === "TSTypeCastExpression") {
|
|
14437
|
+
exprList[i] = this.typeCastToParameter(expr);
|
|
14337
14438
|
}
|
|
14338
14439
|
}
|
|
14339
14440
|
|
|
14340
|
-
|
|
14441
|
+
super.toAssignableList(...arguments);
|
|
14341
14442
|
}
|
|
14342
14443
|
|
|
14343
14444
|
typeCastToParameter(node) {
|
|
@@ -14407,8 +14508,8 @@
|
|
|
14407
14508
|
this.state.inAbstractClass = !!node.abstract;
|
|
14408
14509
|
|
|
14409
14510
|
try {
|
|
14410
|
-
for (var
|
|
14411
|
-
args[
|
|
14511
|
+
for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
|
|
14512
|
+
args[_key6 - 1] = arguments[_key6];
|
|
14412
14513
|
}
|
|
14413
14514
|
|
|
14414
14515
|
return super.parseClass(node, ...args);
|
|
@@ -14532,7 +14633,16 @@
|
|
|
14532
14633
|
}
|
|
14533
14634
|
} else if (tokenIsKeywordOrIdentifier(this.state.type)) {
|
|
14534
14635
|
hasTypeSpecifier = true;
|
|
14535
|
-
|
|
14636
|
+
|
|
14637
|
+
if (isImport) {
|
|
14638
|
+
leftOfAs = this.parseIdentifier(true);
|
|
14639
|
+
|
|
14640
|
+
if (!this.isContextual(93)) {
|
|
14641
|
+
this.checkReservedWord(leftOfAs.name, leftOfAs.loc.start, true, true);
|
|
14642
|
+
}
|
|
14643
|
+
} else {
|
|
14644
|
+
leftOfAs = this.parseModuleExportName();
|
|
14645
|
+
}
|
|
14536
14646
|
}
|
|
14537
14647
|
|
|
14538
14648
|
if (hasTypeSpecifier && isInTypeOnlyImportExport) {
|
|
@@ -14631,8 +14741,8 @@
|
|
|
14631
14741
|
}
|
|
14632
14742
|
|
|
14633
14743
|
isValidLVal(type) {
|
|
14634
|
-
for (var
|
|
14635
|
-
rest[
|
|
14744
|
+
for (var _len7 = arguments.length, rest = new Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) {
|
|
14745
|
+
rest[_key7 - 1] = arguments[_key7];
|
|
14636
14746
|
}
|
|
14637
14747
|
|
|
14638
14748
|
return type === "Placeholder" || super.isValidLVal(type, ...rest);
|
|
@@ -14641,10 +14751,9 @@
|
|
|
14641
14751
|
toAssignable(node) {
|
|
14642
14752
|
if (node && node.type === "Placeholder" && node.expectedNode === "Expression") {
|
|
14643
14753
|
node.expectedNode = "Pattern";
|
|
14644
|
-
|
|
14754
|
+
} else {
|
|
14755
|
+
super.toAssignable(...arguments);
|
|
14645
14756
|
}
|
|
14646
|
-
|
|
14647
|
-
return super.toAssignable(...arguments);
|
|
14648
14757
|
}
|
|
14649
14758
|
|
|
14650
14759
|
isLet(context) {
|
|
@@ -14956,9 +15065,9 @@
|
|
|
14956
15065
|
throw new Error("Cannot combine importAssertions and moduleAttributes plugins.");
|
|
14957
15066
|
}
|
|
14958
15067
|
|
|
14959
|
-
var
|
|
15068
|
+
var moduleAttributesVersionPluginOption = getPluginOption(plugins, "moduleAttributes", "version");
|
|
14960
15069
|
|
|
14961
|
-
if (
|
|
15070
|
+
if (moduleAttributesVersionPluginOption !== "may-2020") {
|
|
14962
15071
|
throw new Error("The 'moduleAttributes' plugin requires a 'version' option," + " representing the last proposal update. Currently, the" + " only supported value is 'may-2020'.");
|
|
14963
15072
|
}
|
|
14964
15073
|
}
|
|
@@ -15032,7 +15141,7 @@
|
|
|
15032
15141
|
|
|
15033
15142
|
if (isLHS) {
|
|
15034
15143
|
if (parenthesized.type === "Identifier") {
|
|
15035
|
-
this.expressionScope.
|
|
15144
|
+
this.expressionScope.recordArrowParemeterBindingError(Errors.InvalidParenthesizedAssignment, {
|
|
15036
15145
|
at: node
|
|
15037
15146
|
});
|
|
15038
15147
|
} else if (parenthesized.type !== "MemberExpression") {
|
|
@@ -15091,11 +15200,7 @@
|
|
|
15091
15200
|
|
|
15092
15201
|
case "SpreadElement":
|
|
15093
15202
|
{
|
|
15094
|
-
this.
|
|
15095
|
-
node.type = "RestElement";
|
|
15096
|
-
var arg = node.argument;
|
|
15097
|
-
this.toAssignable(arg, isLHS);
|
|
15098
|
-
break;
|
|
15203
|
+
throw new Error("Internal @babel/parser error (this is a bug, please report it)." + " SpreadElement should be converted by .toAssignable's caller.");
|
|
15099
15204
|
}
|
|
15100
15205
|
|
|
15101
15206
|
case "ArrayExpression":
|
|
@@ -15119,8 +15224,6 @@
|
|
|
15119
15224
|
this.toAssignable(parenthesized, isLHS);
|
|
15120
15225
|
break;
|
|
15121
15226
|
}
|
|
15122
|
-
|
|
15123
|
-
return node;
|
|
15124
15227
|
}
|
|
15125
15228
|
|
|
15126
15229
|
toAssignableObjectExpressionProp(prop, isLast, isLHS) {
|
|
@@ -15128,58 +15231,50 @@
|
|
|
15128
15231
|
this.raise(prop.kind === "get" || prop.kind === "set" ? Errors.PatternHasAccessor : Errors.PatternHasMethod, {
|
|
15129
15232
|
at: prop.key
|
|
15130
15233
|
});
|
|
15131
|
-
} else if (prop.type === "SpreadElement"
|
|
15132
|
-
|
|
15133
|
-
|
|
15134
|
-
|
|
15234
|
+
} else if (prop.type === "SpreadElement") {
|
|
15235
|
+
prop.type = "RestElement";
|
|
15236
|
+
var arg = prop.argument;
|
|
15237
|
+
this.checkToRestConversion(arg, false);
|
|
15238
|
+
this.toAssignable(arg, isLHS);
|
|
15239
|
+
|
|
15240
|
+
if (!isLast) {
|
|
15241
|
+
this.raise(Errors.RestTrailingComma, {
|
|
15242
|
+
at: prop
|
|
15243
|
+
});
|
|
15244
|
+
}
|
|
15135
15245
|
} else {
|
|
15136
15246
|
this.toAssignable(prop, isLHS);
|
|
15137
15247
|
}
|
|
15138
15248
|
}
|
|
15139
15249
|
|
|
15140
15250
|
toAssignableList(exprList, trailingCommaLoc, isLHS) {
|
|
15141
|
-
var end = exprList.length;
|
|
15142
|
-
|
|
15143
|
-
if (end) {
|
|
15144
|
-
var last = exprList[end - 1];
|
|
15145
|
-
|
|
15146
|
-
if ((last == null ? void 0 : last.type) === "RestElement") {
|
|
15147
|
-
--end;
|
|
15148
|
-
} else if ((last == null ? void 0 : last.type) === "SpreadElement") {
|
|
15149
|
-
last.type = "RestElement";
|
|
15150
|
-
var arg = last.argument;
|
|
15151
|
-
this.toAssignable(arg, isLHS);
|
|
15152
|
-
arg = unwrapParenthesizedExpression(arg);
|
|
15153
|
-
|
|
15154
|
-
if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern" && arg.type !== "ObjectPattern") {
|
|
15155
|
-
this.unexpected(arg.start);
|
|
15156
|
-
}
|
|
15251
|
+
var end = exprList.length - 1;
|
|
15157
15252
|
|
|
15158
|
-
|
|
15159
|
-
this.raise(Errors.RestTrailingComma, {
|
|
15160
|
-
at: trailingCommaLoc
|
|
15161
|
-
});
|
|
15162
|
-
}
|
|
15163
|
-
|
|
15164
|
-
--end;
|
|
15165
|
-
}
|
|
15166
|
-
}
|
|
15167
|
-
|
|
15168
|
-
for (var i = 0; i < end; i++) {
|
|
15253
|
+
for (var i = 0; i <= end; i++) {
|
|
15169
15254
|
var elt = exprList[i];
|
|
15255
|
+
if (!elt) continue;
|
|
15170
15256
|
|
|
15171
|
-
if (elt) {
|
|
15257
|
+
if (elt.type === "SpreadElement") {
|
|
15258
|
+
elt.type = "RestElement";
|
|
15259
|
+
var arg = elt.argument;
|
|
15260
|
+
this.checkToRestConversion(arg, true);
|
|
15261
|
+
this.toAssignable(arg, isLHS);
|
|
15262
|
+
} else {
|
|
15172
15263
|
this.toAssignable(elt, isLHS);
|
|
15264
|
+
}
|
|
15173
15265
|
|
|
15174
|
-
|
|
15266
|
+
if (elt.type === "RestElement") {
|
|
15267
|
+
if (i < end) {
|
|
15175
15268
|
this.raise(Errors.RestTrailingComma, {
|
|
15176
15269
|
at: elt
|
|
15177
15270
|
});
|
|
15271
|
+
} else if (trailingCommaLoc) {
|
|
15272
|
+
this.raise(Errors.RestTrailingComma, {
|
|
15273
|
+
at: trailingCommaLoc
|
|
15274
|
+
});
|
|
15178
15275
|
}
|
|
15179
15276
|
}
|
|
15180
15277
|
}
|
|
15181
|
-
|
|
15182
|
-
return exprList;
|
|
15183
15278
|
}
|
|
15184
15279
|
|
|
15185
15280
|
isAssignable(node, isBinding) {
|
|
@@ -15369,7 +15464,7 @@
|
|
|
15369
15464
|
return this.finishNode(node, "AssignmentPattern");
|
|
15370
15465
|
}
|
|
15371
15466
|
|
|
15372
|
-
isValidLVal(type,
|
|
15467
|
+
isValidLVal(type, isUnparenthesizedInAssign, binding) {
|
|
15373
15468
|
return getOwn({
|
|
15374
15469
|
AssignmentPattern: "left",
|
|
15375
15470
|
RestElement: "argument",
|
|
@@ -15380,7 +15475,7 @@
|
|
|
15380
15475
|
}, type);
|
|
15381
15476
|
}
|
|
15382
15477
|
|
|
15383
|
-
checkLVal(expression,
|
|
15478
|
+
checkLVal(expression, _ref88) {
|
|
15384
15479
|
var {
|
|
15385
15480
|
in: ancestor,
|
|
15386
15481
|
binding = BIND_NONE,
|
|
@@ -15388,7 +15483,7 @@
|
|
|
15388
15483
|
strictModeChanged = false,
|
|
15389
15484
|
allowingSloppyLetBinding = !(binding & BIND_SCOPE_LEXICAL),
|
|
15390
15485
|
hasParenthesizedAncestor = false
|
|
15391
|
-
} =
|
|
15486
|
+
} = _ref88;
|
|
15392
15487
|
|
|
15393
15488
|
var _expression$extra;
|
|
15394
15489
|
|
|
@@ -15424,7 +15519,7 @@
|
|
|
15424
15519
|
return;
|
|
15425
15520
|
}
|
|
15426
15521
|
|
|
15427
|
-
var validity = this.isValidLVal(expression.type, hasParenthesizedAncestor || (
|
|
15522
|
+
var validity = this.isValidLVal(expression.type, !(hasParenthesizedAncestor || (_expression$extra = expression.extra) != null && _expression$extra.parenthesized) && ancestor.type === "AssignmentExpression", binding);
|
|
15428
15523
|
if (validity === true) return;
|
|
15429
15524
|
|
|
15430
15525
|
if (validity === false) {
|
|
@@ -15491,11 +15586,24 @@
|
|
|
15491
15586
|
this.scope.declareName(identifier.name, binding, identifier.loc.start);
|
|
15492
15587
|
}
|
|
15493
15588
|
|
|
15494
|
-
checkToRestConversion(node) {
|
|
15495
|
-
|
|
15496
|
-
|
|
15497
|
-
|
|
15498
|
-
|
|
15589
|
+
checkToRestConversion(node, allowPattern) {
|
|
15590
|
+
switch (node.type) {
|
|
15591
|
+
case "ParenthesizedExpression":
|
|
15592
|
+
this.checkToRestConversion(node.expression, allowPattern);
|
|
15593
|
+
break;
|
|
15594
|
+
|
|
15595
|
+
case "Identifier":
|
|
15596
|
+
case "MemberExpression":
|
|
15597
|
+
break;
|
|
15598
|
+
|
|
15599
|
+
case "ArrayExpression":
|
|
15600
|
+
case "ObjectExpression":
|
|
15601
|
+
if (allowPattern) break;
|
|
15602
|
+
|
|
15603
|
+
default:
|
|
15604
|
+
this.raise(Errors.InvalidRestAssignmentPattern, {
|
|
15605
|
+
at: node
|
|
15606
|
+
});
|
|
15499
15607
|
}
|
|
15500
15608
|
}
|
|
15501
15609
|
|
|
@@ -15656,7 +15764,8 @@
|
|
|
15656
15764
|
node.operator = operator;
|
|
15657
15765
|
|
|
15658
15766
|
if (this.match(29)) {
|
|
15659
|
-
|
|
15767
|
+
this.toAssignable(left, true);
|
|
15768
|
+
node.left = left;
|
|
15660
15769
|
|
|
15661
15770
|
if (refExpressionErrors.doubleProtoLoc != null && refExpressionErrors.doubleProtoLoc.index >= startPos) {
|
|
15662
15771
|
refExpressionErrors.doubleProtoLoc = null;
|
|
@@ -15956,14 +16065,14 @@
|
|
|
15956
16065
|
if (this.checkExpressionErrors(refExpressionErrors, false)) return expr;
|
|
15957
16066
|
|
|
15958
16067
|
while (tokenIsPostfix(this.state.type) && !this.canInsertSemicolon()) {
|
|
15959
|
-
var
|
|
16068
|
+
var _node10 = this.startNodeAt(startPos, startLoc);
|
|
15960
16069
|
|
|
15961
|
-
|
|
15962
|
-
|
|
15963
|
-
|
|
16070
|
+
_node10.operator = this.state.value;
|
|
16071
|
+
_node10.prefix = false;
|
|
16072
|
+
_node10.argument = expr;
|
|
15964
16073
|
this.next();
|
|
15965
16074
|
this.checkLVal(expr, {
|
|
15966
|
-
in: expr = this.finishNode(
|
|
16075
|
+
in: expr = this.finishNode(_node10, "UpdateExpression")
|
|
15967
16076
|
});
|
|
15968
16077
|
}
|
|
15969
16078
|
|
|
@@ -16823,6 +16932,20 @@
|
|
|
16823
16932
|
}
|
|
16824
16933
|
|
|
16825
16934
|
parseNew(node) {
|
|
16935
|
+
this.parseNewCallee(node);
|
|
16936
|
+
|
|
16937
|
+
if (this.eat(10)) {
|
|
16938
|
+
var args = this.parseExprList(11);
|
|
16939
|
+
this.toReferencedList(args);
|
|
16940
|
+
node.arguments = args;
|
|
16941
|
+
} else {
|
|
16942
|
+
node.arguments = [];
|
|
16943
|
+
}
|
|
16944
|
+
|
|
16945
|
+
return this.finishNode(node, "NewExpression");
|
|
16946
|
+
}
|
|
16947
|
+
|
|
16948
|
+
parseNewCallee(node) {
|
|
16826
16949
|
node.callee = this.parseNoCallExpr();
|
|
16827
16950
|
|
|
16828
16951
|
if (node.callee.type === "Import") {
|
|
@@ -16838,19 +16961,6 @@
|
|
|
16838
16961
|
at: this.state.startLoc
|
|
16839
16962
|
});
|
|
16840
16963
|
}
|
|
16841
|
-
|
|
16842
|
-
this.parseNewArguments(node);
|
|
16843
|
-
return this.finishNode(node, "NewExpression");
|
|
16844
|
-
}
|
|
16845
|
-
|
|
16846
|
-
parseNewArguments(node) {
|
|
16847
|
-
if (this.eat(10)) {
|
|
16848
|
-
var args = this.parseExprList(11);
|
|
16849
|
-
this.toReferencedList(args);
|
|
16850
|
-
node.arguments = args;
|
|
16851
|
-
} else {
|
|
16852
|
-
node.arguments = [];
|
|
16853
|
-
}
|
|
16854
16964
|
}
|
|
16855
16965
|
|
|
16856
16966
|
parseTemplateElement(isTagged) {
|
|
@@ -17257,7 +17367,8 @@
|
|
|
17257
17367
|
}
|
|
17258
17368
|
|
|
17259
17369
|
setArrowFunctionParameters(node, params, trailingCommaLoc) {
|
|
17260
|
-
|
|
17370
|
+
this.toAssignableList(params, trailingCommaLoc, false);
|
|
17371
|
+
node.params = params;
|
|
17261
17372
|
}
|
|
17262
17373
|
|
|
17263
17374
|
parseFunctionBodyAndFinish(node, type) {
|
|
@@ -18198,12 +18309,12 @@
|
|
|
18198
18309
|
expr = this.parseIdentifier(false);
|
|
18199
18310
|
|
|
18200
18311
|
while (this.eat(16)) {
|
|
18201
|
-
var
|
|
18312
|
+
var _node11 = this.startNodeAt(startPos, startLoc);
|
|
18202
18313
|
|
|
18203
|
-
|
|
18204
|
-
|
|
18205
|
-
|
|
18206
|
-
expr = this.finishNode(
|
|
18314
|
+
_node11.object = expr;
|
|
18315
|
+
_node11.property = this.parseIdentifier(true);
|
|
18316
|
+
_node11.computed = false;
|
|
18317
|
+
expr = this.finishNode(_node11, "MemberExpression");
|
|
18207
18318
|
}
|
|
18208
18319
|
}
|
|
18209
18320
|
|