Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a422ea64ee | ||
|
|
34d30e28d6 | ||
|
|
3ad4c70d3a | ||
|
|
34937f13d5 | ||
|
|
c7add11fdc |
41
CHANGELOG.md
41
CHANGELOG.md
@@ -17,6 +17,47 @@ See [Babylon's CHANGELOG](packages/babylon/CHANGELOG.md) for the Babylon pre-7.0
|
||||
|
||||
<!-- DO NOT CHANGE THESE COMMENTS - See .github/actions/trigger-github-release/update-changelog.js -->
|
||||
<!-- insert-new-changelog-here -->
|
||||
## v7.6.3 (2019-10-08)
|
||||
|
||||
#### :eyeglasses: Spec Compliance
|
||||
* `babel-parser`
|
||||
* [#10469](https://github.com/babel/babel/pull/10469) Disallow await inside async arrow params ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* [#10493](https://github.com/babel/babel/pull/10493) [parser] Disallow numeric separators in legacy octal like integers ([@gonzarodriguezt](https://github.com/gonzarodriguezt))
|
||||
|
||||
#### :rocket: New Feature
|
||||
* `babel-types`
|
||||
* [#10504](https://github.com/babel/babel/pull/10504) Add declarations for more of @babel/types exports ([@Jessidhia](https://github.com/Jessidhia))
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-plugin-transform-block-scoping`
|
||||
* [#10343](https://github.com/babel/babel/pull/10343) Do not remove let bindings even they are wrapped in closure ([@JLHwung](https://github.com/JLHwung))
|
||||
* `babel-parser`
|
||||
* [#10119](https://github.com/babel/babel/pull/10119) add scope to TSModuleDeclaration ([@tanhauhau](https://github.com/tanhauhau))
|
||||
* [#10332](https://github.com/babel/babel/pull/10332) Do not allow member expressions to start async arrows ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* [#10490](https://github.com/babel/babel/pull/10490) [parser] Don't crash on comment after trailing comma after elision ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-plugin-transform-react-constant-elements`, `babel-traverse`
|
||||
* [#10529](https://github.com/babel/babel/pull/10529) Do not hoist jsx referencing a mutable binding ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-generator`, `babel-parser`, `babel-plugin-transform-block-scoping`, `babel-plugin-transform-flow-comments`, `babel-plugin-transform-flow-strip-types`, `babel-plugin-transform-typescript`
|
||||
* [#10220](https://github.com/babel/babel/pull/10220) Flow: interface identifier should be declared in the scope ([@JLHwung](https://github.com/JLHwung))
|
||||
|
||||
#### :nail_care: Polish
|
||||
* `babel-core`
|
||||
* [#10419](https://github.com/babel/babel/pull/10419) assertNoDuplicates throw with more context ([@hjdivad](https://github.com/hjdivad))
|
||||
* [#10511](https://github.com/babel/babel/pull/10511) Add filename to transform error ([@JLHwung](https://github.com/JLHwung))
|
||||
|
||||
#### :house: Internal
|
||||
* Other
|
||||
* [#10506](https://github.com/babel/babel/pull/10506) Use `make -j` for parallel build ([@JLHwung](https://github.com/JLHwung))
|
||||
* [#10443](https://github.com/babel/babel/pull/10443) perf: only apply lazy cjs module transform on cli and core ([@JLHwung](https://github.com/JLHwung))
|
||||
* [#10494](https://github.com/babel/babel/pull/10494) Enable optional chaining and nullish coalescing plugins ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-cli`, `babel-core`, `babel-generator`, `babel-helper-fixtures`, `babel-helper-transform-fixture-test-runner`, `babel-node`, `babel-plugin-transform-react-jsx-source`, `babel-plugin-transform-runtime`, `babel-preset-env`, `babel-preset-react`
|
||||
* [#10249](https://github.com/babel/babel/pull/10249) Add windows to travis ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
|
||||
#### :running_woman: Performance
|
||||
* `babel-parser`
|
||||
* [#10371](https://github.com/babel/babel/pull/10371) perf: replace lookahead by lookaheadCharCode ([@JLHwung](https://github.com/JLHwung))
|
||||
* Other
|
||||
* [#10443](https://github.com/babel/babel/pull/10443) perf: only apply lazy cjs module transform on cli and core ([@JLHwung](https://github.com/JLHwung))
|
||||
## v7.6.2 (2019-09-23)
|
||||
|
||||
#### :eyeglasses: Spec Compliance
|
||||
|
||||
2
Makefile
2
Makefile
@@ -179,7 +179,7 @@ clone-license:
|
||||
./scripts/clone-license.sh
|
||||
|
||||
prepublish-build: clean-lib clean-runtime-helpers
|
||||
NODE_ENV=production BABEL_ENV=production $(MAKE) build-dist
|
||||
NODE_ENV=production BABEL_ENV=production $(MAKE) build
|
||||
$(MAKE) clone-license
|
||||
|
||||
prepublish:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "7.6.3",
|
||||
"version": "7.6.4",
|
||||
"changelog": {
|
||||
"repo": "babel/babel",
|
||||
"cacheDir": ".changelog",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/cli",
|
||||
"version": "7.6.3",
|
||||
"version": "7.6.4",
|
||||
"description": "Babel command line.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -27,7 +27,7 @@
|
||||
"mkdirp": "^0.5.1",
|
||||
"output-file-sync": "^2.0.0",
|
||||
"slash": "^2.0.0",
|
||||
"source-map": "^0.6.1"
|
||||
"source-map": "^0.5.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"chokidar": "^2.1.8"
|
||||
@@ -36,7 +36,7 @@
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.6.3",
|
||||
"@babel/core": "^7.6.4",
|
||||
"@babel/helper-fixtures": "^7.6.3"
|
||||
},
|
||||
"bin": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/core",
|
||||
"version": "7.6.3",
|
||||
"version": "7.6.4",
|
||||
"description": "Babel compiler core.",
|
||||
"main": "lib/index.js",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
@@ -34,9 +34,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.5.5",
|
||||
"@babel/generator": "^7.6.3",
|
||||
"@babel/generator": "^7.6.4",
|
||||
"@babel/helpers": "^7.6.2",
|
||||
"@babel/parser": "^7.6.3",
|
||||
"@babel/parser": "^7.6.4",
|
||||
"@babel/template": "^7.6.0",
|
||||
"@babel/traverse": "^7.6.3",
|
||||
"@babel/types": "^7.6.3",
|
||||
@@ -46,9 +46,9 @@
|
||||
"lodash": "^4.17.13",
|
||||
"resolve": "^1.3.2",
|
||||
"semver": "^5.4.1",
|
||||
"source-map": "^0.6.1"
|
||||
"source-map": "^0.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-transform-fixture-test-runner": "^7.6.3"
|
||||
"@babel/helper-transform-fixture-test-runner": "^7.6.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/generator",
|
||||
"version": "7.6.3",
|
||||
"version": "7.6.4",
|
||||
"description": "Turns an AST into code.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -17,10 +17,10 @@
|
||||
"@babel/types": "^7.6.3",
|
||||
"jsesc": "^2.5.1",
|
||||
"lodash": "^4.17.13",
|
||||
"source-map": "^0.6.1"
|
||||
"source-map": "^0.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-fixtures": "^7.6.3",
|
||||
"@babel/parser": "^7.6.3"
|
||||
"@babel/parser": "^7.6.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-transform-fixture-test-runner",
|
||||
"version": "7.6.3",
|
||||
"version": "7.6.4",
|
||||
"description": "Transform test runner for @babel/helper-fixtures module",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -12,7 +12,7 @@
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.5.5",
|
||||
"@babel/core": "^7.6.3",
|
||||
"@babel/core": "^7.6.4",
|
||||
"@babel/helper-fixtures": "^7.6.3",
|
||||
"@babel/polyfill": "^7.6.0",
|
||||
"babel-check-duplicated-nodes": "^1.0.0",
|
||||
@@ -20,6 +20,6 @@
|
||||
"jest-diff": "^24.8.0",
|
||||
"lodash": "^4.17.13",
|
||||
"resolve": "^1.3.2",
|
||||
"source-map": "^0.6.1"
|
||||
"source-map": "^0.5.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/parser",
|
||||
"version": "7.6.3",
|
||||
"version": "7.6.4",
|
||||
"description": "A JavaScript parser",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
|
||||
@@ -168,9 +168,6 @@ export default class ExpressionParser extends LValParser {
|
||||
}
|
||||
}
|
||||
|
||||
const oldCommaAfterSpreadAt = this.state.commaAfterSpreadAt;
|
||||
this.state.commaAfterSpreadAt = -1;
|
||||
|
||||
let failOnShorthandAssign;
|
||||
if (refShorthandDefaultPos) {
|
||||
failOnShorthandAssign = false;
|
||||
@@ -230,9 +227,6 @@ export default class ExpressionParser extends LValParser {
|
||||
);
|
||||
}
|
||||
|
||||
if (patternErrorMsg) this.checkCommaAfterRestFromSpread();
|
||||
this.state.commaAfterSpreadAt = oldCommaAfterSpreadAt;
|
||||
|
||||
this.next();
|
||||
node.right = this.parseMaybeAssign(noIn);
|
||||
return this.finishNode(node, "AssignmentExpression");
|
||||
@@ -240,8 +234,6 @@ export default class ExpressionParser extends LValParser {
|
||||
this.unexpected(refShorthandDefaultPos.start);
|
||||
}
|
||||
|
||||
this.state.commaAfterSpreadAt = oldCommaAfterSpreadAt;
|
||||
|
||||
return left;
|
||||
}
|
||||
|
||||
@@ -680,14 +672,12 @@ export default class ExpressionParser extends LValParser {
|
||||
let node = this.startNodeAt(startPos, startLoc);
|
||||
node.callee = base;
|
||||
|
||||
const oldCommaAfterSpreadAt = this.state.commaAfterSpreadAt;
|
||||
this.state.commaAfterSpreadAt = -1;
|
||||
|
||||
node.arguments = this.parseCallExpressionArguments(
|
||||
tt.parenR,
|
||||
state.maybeAsyncArrow,
|
||||
base.type === "Import",
|
||||
base.type !== "Super",
|
||||
node,
|
||||
);
|
||||
if (!state.optionalChainMember) {
|
||||
this.finishCallExpression(node);
|
||||
@@ -698,8 +688,6 @@ export default class ExpressionParser extends LValParser {
|
||||
if (state.maybeAsyncArrow && this.shouldParseAsyncArrow()) {
|
||||
state.stop = true;
|
||||
|
||||
this.checkCommaAfterRestFromSpread();
|
||||
|
||||
node = this.parseAsyncArrowFromCallExpression(
|
||||
this.startNodeAt(startPos, startLoc),
|
||||
node,
|
||||
@@ -743,7 +731,6 @@ export default class ExpressionParser extends LValParser {
|
||||
}
|
||||
|
||||
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
||||
this.state.commaAfterSpreadAt = oldCommaAfterSpreadAt;
|
||||
|
||||
return node;
|
||||
} else if (this.match(tt.backQuote)) {
|
||||
@@ -825,6 +812,7 @@ export default class ExpressionParser extends LValParser {
|
||||
possibleAsyncArrow: boolean,
|
||||
dynamicImport?: boolean,
|
||||
allowPlaceholder?: boolean,
|
||||
nodeForExtra?: ?N.Node,
|
||||
): $ReadOnlyArray<?N.Expression> {
|
||||
const elts = [];
|
||||
let innerParenStart;
|
||||
@@ -837,13 +825,21 @@ export default class ExpressionParser extends LValParser {
|
||||
first = false;
|
||||
} else {
|
||||
this.expect(tt.comma);
|
||||
if (this.eat(close)) {
|
||||
if (this.match(close)) {
|
||||
if (dynamicImport) {
|
||||
this.raise(
|
||||
this.state.lastTokStart,
|
||||
"Trailing comma is disallowed inside import(...) arguments",
|
||||
);
|
||||
}
|
||||
if (nodeForExtra) {
|
||||
this.addExtra(
|
||||
nodeForExtra,
|
||||
"trailingComma",
|
||||
this.state.lastTokStart,
|
||||
);
|
||||
}
|
||||
this.next();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -883,7 +879,12 @@ export default class ExpressionParser extends LValParser {
|
||||
call: N.CallExpression,
|
||||
): N.ArrowFunctionExpression {
|
||||
this.expect(tt.arrow);
|
||||
this.parseArrowExpression(node, call.arguments, true);
|
||||
this.parseArrowExpression(
|
||||
node,
|
||||
call.arguments,
|
||||
true,
|
||||
call.extra?.trailingComma,
|
||||
);
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -1046,6 +1047,7 @@ export default class ExpressionParser extends LValParser {
|
||||
tt.bracketR,
|
||||
true,
|
||||
refShorthandDefaultPos,
|
||||
node,
|
||||
);
|
||||
if (!this.state.maybeInArrowParameters) {
|
||||
// This could be an array pattern:
|
||||
@@ -1289,7 +1291,7 @@ export default class ExpressionParser extends LValParser {
|
||||
),
|
||||
);
|
||||
|
||||
this.checkCommaAfterRest();
|
||||
this.checkCommaAfterRest(charCodes.rightParenthesis);
|
||||
|
||||
break;
|
||||
} else {
|
||||
@@ -1504,7 +1506,11 @@ export default class ExpressionParser extends LValParser {
|
||||
first = false;
|
||||
} else {
|
||||
this.expect(tt.comma);
|
||||
if (this.eat(tt.braceR)) break;
|
||||
if (this.match(tt.braceR)) {
|
||||
this.addExtra(node, "trailingComma", this.state.lastTokStart);
|
||||
this.next();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const prop = this.parseObjectMember(isPattern, refShorthandDefaultPos);
|
||||
@@ -1572,7 +1578,7 @@ export default class ExpressionParser extends LValParser {
|
||||
this.next();
|
||||
// Don't use parseRestBinding() as we only allow Identifier here.
|
||||
prop.argument = this.parseIdentifier();
|
||||
this.checkCommaAfterRest();
|
||||
this.checkCommaAfterRest(charCodes.rightCurlyBrace);
|
||||
return this.finishNode(prop, "RestElement");
|
||||
}
|
||||
|
||||
@@ -1856,6 +1862,7 @@ export default class ExpressionParser extends LValParser {
|
||||
node: N.ArrowFunctionExpression,
|
||||
params: ?(N.Expression[]),
|
||||
isAsync: boolean,
|
||||
trailingCommaPos: ?number,
|
||||
): N.ArrowFunctionExpression {
|
||||
this.scope.enter(functionFlags(isAsync, false) | SCOPE_ARROW);
|
||||
this.initFunction(node, isAsync);
|
||||
@@ -1867,7 +1874,7 @@ export default class ExpressionParser extends LValParser {
|
||||
this.state.yieldPos = -1;
|
||||
this.state.awaitPos = -1;
|
||||
|
||||
if (params) this.setArrowFunctionParameters(node, params);
|
||||
if (params) this.setArrowFunctionParameters(node, params, trailingCommaPos);
|
||||
this.parseFunctionBody(node, true);
|
||||
|
||||
this.scope.exit();
|
||||
@@ -1881,11 +1888,13 @@ export default class ExpressionParser extends LValParser {
|
||||
setArrowFunctionParameters(
|
||||
node: N.ArrowFunctionExpression,
|
||||
params: N.Expression[],
|
||||
trailingCommaPos: ?number,
|
||||
): void {
|
||||
node.params = this.toAssignableList(
|
||||
params,
|
||||
true,
|
||||
"arrow function parameters",
|
||||
trailingCommaPos,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2012,6 +2021,7 @@ export default class ExpressionParser extends LValParser {
|
||||
close: TokenType,
|
||||
allowEmpty?: boolean,
|
||||
refShorthandDefaultPos?: ?Pos,
|
||||
nodeForExtra?: ?N.Node,
|
||||
): $ReadOnlyArray<?N.Expression> {
|
||||
const elts = [];
|
||||
let first = true;
|
||||
@@ -2021,7 +2031,17 @@ export default class ExpressionParser extends LValParser {
|
||||
first = false;
|
||||
} else {
|
||||
this.expect(tt.comma);
|
||||
if (this.eat(close)) break;
|
||||
if (this.match(close)) {
|
||||
if (nodeForExtra) {
|
||||
this.addExtra(
|
||||
nodeForExtra,
|
||||
"trailingComma",
|
||||
this.state.lastTokStart,
|
||||
);
|
||||
}
|
||||
this.next();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
elts.push(this.parseExprListItem(allowEmpty, refShorthandDefaultPos));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// @flow
|
||||
|
||||
import * as charCodes from "charcodes";
|
||||
import { types as tt, type TokenType } from "../tokenizer/types";
|
||||
import type {
|
||||
TSParameterProperty,
|
||||
@@ -60,6 +61,14 @@ export default class LValParser extends NodeUtils {
|
||||
const prop = node.properties[i];
|
||||
const isLast = i === last;
|
||||
this.toAssignableObjectExpressionProp(prop, isBinding, isLast);
|
||||
|
||||
if (
|
||||
isLast &&
|
||||
prop.type === "RestElement" &&
|
||||
node.extra?.trailingComma
|
||||
) {
|
||||
this.raiseRestNotLast(node.extra.trailingComma);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -78,7 +87,12 @@ export default class LValParser extends NodeUtils {
|
||||
|
||||
case "ArrayExpression":
|
||||
node.type = "ArrayPattern";
|
||||
this.toAssignableList(node.elements, isBinding, contextDescription);
|
||||
this.toAssignableList(
|
||||
node.elements,
|
||||
isBinding,
|
||||
contextDescription,
|
||||
node.extra?.trailingComma,
|
||||
);
|
||||
break;
|
||||
|
||||
case "AssignmentExpression":
|
||||
@@ -142,6 +156,7 @@ export default class LValParser extends NodeUtils {
|
||||
exprList: Expression[],
|
||||
isBinding: ?boolean,
|
||||
contextDescription: string,
|
||||
trailingCommaPos?: ?number,
|
||||
): $ReadOnlyArray<Pattern> {
|
||||
let end = exprList.length;
|
||||
if (end) {
|
||||
@@ -160,6 +175,11 @@ export default class LValParser extends NodeUtils {
|
||||
) {
|
||||
this.unexpected(arg.start);
|
||||
}
|
||||
|
||||
if (trailingCommaPos) {
|
||||
this.raiseTrailingCommaAfterRest(trailingCommaPos);
|
||||
}
|
||||
|
||||
--end;
|
||||
}
|
||||
}
|
||||
@@ -213,11 +233,6 @@ export default class LValParser extends NodeUtils {
|
||||
undefined,
|
||||
refNeedsArrowPos,
|
||||
);
|
||||
|
||||
if (this.state.commaAfterSpreadAt === -1 && this.match(tt.comma)) {
|
||||
this.state.commaAfterSpreadAt = this.state.start;
|
||||
}
|
||||
|
||||
return this.finishNode(node, "SpreadElement");
|
||||
}
|
||||
|
||||
@@ -234,7 +249,11 @@ export default class LValParser extends NodeUtils {
|
||||
case tt.bracketL: {
|
||||
const node = this.startNode();
|
||||
this.next();
|
||||
node.elements = this.parseBindingList(tt.bracketR, true);
|
||||
node.elements = this.parseBindingList(
|
||||
tt.bracketR,
|
||||
charCodes.rightSquareBracket,
|
||||
true,
|
||||
);
|
||||
return this.finishNode(node, "ArrayPattern");
|
||||
}
|
||||
|
||||
@@ -247,6 +266,7 @@ export default class LValParser extends NodeUtils {
|
||||
|
||||
parseBindingList(
|
||||
close: TokenType,
|
||||
closeCharCode: $Values<typeof charCodes>,
|
||||
allowEmpty?: boolean,
|
||||
allowModifiers?: boolean,
|
||||
): $ReadOnlyArray<Pattern | TSParameterProperty> {
|
||||
@@ -265,7 +285,7 @@ export default class LValParser extends NodeUtils {
|
||||
break;
|
||||
} else if (this.match(tt.ellipsis)) {
|
||||
elts.push(this.parseAssignableListItemTypes(this.parseRestBinding()));
|
||||
this.checkCommaAfterRest();
|
||||
this.checkCommaAfterRest(closeCharCode);
|
||||
this.expect(close);
|
||||
break;
|
||||
} else {
|
||||
@@ -455,19 +475,21 @@ export default class LValParser extends NodeUtils {
|
||||
}
|
||||
}
|
||||
|
||||
checkCommaAfterRest(): void {
|
||||
checkCommaAfterRest(close: $Values<typeof charCodes>): void {
|
||||
if (this.match(tt.comma)) {
|
||||
this.raiseRestNotLast(this.state.start);
|
||||
}
|
||||
}
|
||||
|
||||
checkCommaAfterRestFromSpread(): void {
|
||||
if (this.state.commaAfterSpreadAt > -1) {
|
||||
this.raiseRestNotLast(this.state.commaAfterSpreadAt);
|
||||
if (this.lookaheadCharCode() === close) {
|
||||
this.raiseTrailingCommaAfterRest(this.state.start);
|
||||
} else {
|
||||
this.raiseRestNotLast(this.state.start);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
raiseRestNotLast(pos: number) {
|
||||
this.raise(pos, `Rest element must be last element`);
|
||||
}
|
||||
|
||||
raiseTrailingCommaAfterRest(pos: number) {
|
||||
this.raise(pos, `Unexpected trailing comma after rest element`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1105,6 +1105,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
this.expect(tt.parenL);
|
||||
node.params = this.parseBindingList(
|
||||
tt.parenR,
|
||||
charCodes.rightParenthesis,
|
||||
/* allowEmpty */ false,
|
||||
allowModifiers,
|
||||
);
|
||||
|
||||
@@ -1798,6 +1798,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
((node.params: any): N.Expression[]),
|
||||
true,
|
||||
"arrow function parameters",
|
||||
node.extra?.trailingComma,
|
||||
);
|
||||
// Enter scope, as checkParams defines bindings
|
||||
this.scope.enter(functionFlags(false, false) | SCOPE_ARROW);
|
||||
@@ -1820,6 +1821,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
((node.params: any): N.Expression[]),
|
||||
true,
|
||||
"arrow function parameters",
|
||||
node.extra?.trailingComma,
|
||||
);
|
||||
}
|
||||
return [arrows, []];
|
||||
@@ -1831,6 +1833,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
((node.params: any): N.Expression[]),
|
||||
true,
|
||||
"arrow function parameters",
|
||||
node.extra?.trailingComma,
|
||||
);
|
||||
return true;
|
||||
} catch (err) {
|
||||
@@ -2005,6 +2008,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
exprList: N.Expression[],
|
||||
isBinding: ?boolean,
|
||||
contextDescription: string,
|
||||
trailingCommaPos?: ?number,
|
||||
): $ReadOnlyArray<N.Pattern> {
|
||||
for (let i = 0; i < exprList.length; i++) {
|
||||
const expr = exprList[i];
|
||||
@@ -2012,7 +2016,12 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
exprList[i] = this.typeCastToParameter(expr);
|
||||
}
|
||||
}
|
||||
return super.toAssignableList(exprList, isBinding, contextDescription);
|
||||
return super.toAssignableList(
|
||||
exprList,
|
||||
isBinding,
|
||||
contextDescription,
|
||||
trailingCommaPos,
|
||||
);
|
||||
}
|
||||
|
||||
// this is a list of nodes, from something like a call expression, we need to filter the
|
||||
|
||||
@@ -363,21 +363,23 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
tsParseBindingListForSignature(): $ReadOnlyArray<
|
||||
N.Identifier | N.RestElement | N.ObjectPattern | N.ArrayPattern,
|
||||
> {
|
||||
return this.parseBindingList(tt.parenR).map(pattern => {
|
||||
if (
|
||||
pattern.type !== "Identifier" &&
|
||||
pattern.type !== "RestElement" &&
|
||||
pattern.type !== "ObjectPattern" &&
|
||||
pattern.type !== "ArrayPattern"
|
||||
) {
|
||||
throw this.unexpected(
|
||||
pattern.start,
|
||||
"Name in a signature must be an Identifier, ObjectPattern or ArrayPattern," +
|
||||
`instead got ${pattern.type}`,
|
||||
);
|
||||
}
|
||||
return pattern;
|
||||
});
|
||||
return this.parseBindingList(tt.parenR, charCodes.rightParenthesis).map(
|
||||
pattern => {
|
||||
if (
|
||||
pattern.type !== "Identifier" &&
|
||||
pattern.type !== "RestElement" &&
|
||||
pattern.type !== "ObjectPattern" &&
|
||||
pattern.type !== "ArrayPattern"
|
||||
) {
|
||||
throw this.unexpected(
|
||||
pattern.start,
|
||||
"Name in a signature must be an Identifier, ObjectPattern or ArrayPattern," +
|
||||
`instead got ${pattern.type}`,
|
||||
);
|
||||
}
|
||||
return pattern;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
tsParseTypeMemberSemicolon(): void {
|
||||
@@ -586,7 +588,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
const restNode: N.TsRestType = this.startNode();
|
||||
this.next(); // skips ellipsis
|
||||
restNode.typeAnnotation = this.tsParseType();
|
||||
this.checkCommaAfterRest();
|
||||
this.checkCommaAfterRest(charCodes.rightSquareBracket);
|
||||
return this.finishNode(restNode, "TSRestType");
|
||||
}
|
||||
|
||||
@@ -2363,11 +2365,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
}
|
||||
|
||||
toAssignableList(
|
||||
exprList: N.Expression[],
|
||||
isBinding: ?boolean,
|
||||
contextDescription: string,
|
||||
): $ReadOnlyArray<N.Pattern> {
|
||||
toAssignableList(exprList: N.Expression[]): $ReadOnlyArray<N.Pattern> {
|
||||
for (let i = 0; i < exprList.length; i++) {
|
||||
const expr = exprList[i];
|
||||
if (!expr) continue;
|
||||
@@ -2384,7 +2382,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
break;
|
||||
}
|
||||
}
|
||||
return super.toAssignableList(exprList, isBinding, contextDescription);
|
||||
return super.toAssignableList(...arguments);
|
||||
}
|
||||
|
||||
typeCastToParameter(node: N.TsTypeCastExpression): N.Node {
|
||||
|
||||
@@ -55,11 +55,6 @@ export default class State {
|
||||
// ^
|
||||
noArrowParamsConversionAt: number[] = [];
|
||||
|
||||
// A comma after "...a" is only allowed in spread, but not in rest.
|
||||
// Since we parse destructuring patterns as array/object literals
|
||||
// and then convert them, we need to track it.
|
||||
commaAfterSpreadAt: number = -1;
|
||||
|
||||
// Flags to track
|
||||
inParameters: boolean = false;
|
||||
maybeInArrowParameters: boolean = false;
|
||||
|
||||
@@ -373,7 +373,10 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 140
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -494,7 +497,10 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 200
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
@@ -74,6 +74,9 @@
|
||||
},
|
||||
"name": "fn"
|
||||
},
|
||||
"extra": {
|
||||
"trailingComma": 11
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
|
||||
@@ -74,6 +74,9 @@
|
||||
},
|
||||
"name": "fn"
|
||||
},
|
||||
"extra": {
|
||||
"trailingComma": 7
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
|
||||
@@ -181,6 +181,9 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 35
|
||||
},
|
||||
"trailingComments": [
|
||||
{
|
||||
"type": "CommentBlock",
|
||||
|
||||
@@ -309,7 +309,10 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 66
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
@@ -163,7 +163,10 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 13
|
||||
}
|
||||
}
|
||||
},
|
||||
"trailingComments": [
|
||||
|
||||
@@ -110,7 +110,10 @@
|
||||
},
|
||||
"value": 42
|
||||
}
|
||||
]
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 8
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,10 @@
|
||||
},
|
||||
"value": 3
|
||||
}
|
||||
]
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 13
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,10 @@
|
||||
},
|
||||
"value": 3
|
||||
}
|
||||
]
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 14
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Rest element must be last element (1:5)"
|
||||
"throws": "Unexpected trailing comma after rest element (1:5)"
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
for ([...a,] in []);
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected trailing comma after rest element (1:10)"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
[[...a,]] = [];
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected trailing comma after rest element (1:6)"
|
||||
}
|
||||
@@ -90,7 +90,10 @@
|
||||
"name": "a"
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 5
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Rest element must be last element (1:8)"
|
||||
"throws": "Unexpected trailing comma after rest element (1:8)"
|
||||
}
|
||||
|
||||
@@ -91,7 +91,10 @@
|
||||
"name": "x"
|
||||
},
|
||||
null
|
||||
]
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 3
|
||||
}
|
||||
},
|
||||
"right": {
|
||||
"type": "NumericLiteral",
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Rest element must be last element (1:11)"
|
||||
}
|
||||
"throws": "Unexpected trailing comma after rest element (1:11)"
|
||||
}
|
||||
@@ -74,6 +74,9 @@
|
||||
},
|
||||
"name": "log"
|
||||
},
|
||||
"extra": {
|
||||
"trailingComma": 13
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
|
||||
@@ -183,7 +183,10 @@
|
||||
"shorthand": true
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 10
|
||||
}
|
||||
},
|
||||
"init": {
|
||||
"type": "Identifier",
|
||||
|
||||
@@ -289,6 +289,7 @@
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 21,
|
||||
"parenthesized": true,
|
||||
"parenStart": 0
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Rest element must be last element (1:16)"
|
||||
"throws": "Unexpected trailing comma after rest element (1:16)"
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
for ({...a,} in []);
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Rest element must be last element (1:10)"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
[{...a,}] = [];
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Rest element must be last element (1:6)"
|
||||
}
|
||||
@@ -92,6 +92,7 @@
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 6,
|
||||
"parenthesized": true,
|
||||
"parenStart": 0
|
||||
}
|
||||
|
||||
@@ -78,7 +78,10 @@
|
||||
"elements": [
|
||||
null,
|
||||
null
|
||||
]
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 3
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
|
||||
@@ -75,7 +75,10 @@
|
||||
"elements": [
|
||||
null,
|
||||
null
|
||||
]
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 2
|
||||
}
|
||||
},
|
||||
"right": {
|
||||
"type": "NumericLiteral",
|
||||
|
||||
@@ -166,6 +166,7 @@
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 33,
|
||||
"parenthesized": true,
|
||||
"parenStart": 0
|
||||
}
|
||||
|
||||
@@ -169,6 +169,7 @@
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 35,
|
||||
"parenthesized": true,
|
||||
"parenStart": 0
|
||||
}
|
||||
|
||||
@@ -128,7 +128,10 @@
|
||||
"shorthand": true
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 6
|
||||
}
|
||||
},
|
||||
"init": {
|
||||
"type": "NumericLiteral",
|
||||
|
||||
@@ -110,7 +110,10 @@
|
||||
},
|
||||
"value": 42
|
||||
}
|
||||
]
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 8
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,10 @@
|
||||
},
|
||||
"value": 3
|
||||
}
|
||||
]
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 13
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,10 @@
|
||||
},
|
||||
"value": 3
|
||||
}
|
||||
]
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 14
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Trailing comma is disallowed inside import(...) arguments (1:13)"
|
||||
"throws": "Trailing comma is disallowed inside import(...) arguments (1:12)"
|
||||
}
|
||||
|
||||
@@ -157,7 +157,10 @@
|
||||
},
|
||||
"value": 123
|
||||
}
|
||||
]
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 24
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
@@ -187,7 +187,6 @@
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"attributes": [],
|
||||
"name": {
|
||||
"type": "JSXIdentifier",
|
||||
"start": 29,
|
||||
@@ -204,6 +203,7 @@
|
||||
},
|
||||
"name": "Foo"
|
||||
},
|
||||
"attributes": [],
|
||||
"selfClosing": true
|
||||
},
|
||||
"closingElement": null,
|
||||
@@ -263,7 +263,10 @@
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 39
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
@@ -450,7 +450,10 @@
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
"extra": {
|
||||
"trailingComma": 77
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/standalone",
|
||||
"version": "7.6.3",
|
||||
"version": "7.6.4",
|
||||
"description": "Standalone build of Babel for use in non-Node.js environments.",
|
||||
"main": "babel.js",
|
||||
"files": [
|
||||
@@ -9,7 +9,7 @@
|
||||
"src"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.6.3",
|
||||
"@babel/core": "^7.6.4",
|
||||
"@babel/helper-plugin-utils": "^7.0.0",
|
||||
"@babel/plugin-external-helpers": "^7.2.0",
|
||||
"@babel/plugin-proposal-async-generator-functions": "^7.2.0",
|
||||
|
||||
@@ -645,12 +645,4 @@ language/statements/class/elements/syntax/early-errors/invalid-names/method-outt
|
||||
language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-member-expression-bad-reference.js(default)
|
||||
language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-member-expression-bad-reference.js(strict mode)
|
||||
language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-member-expression-this.js(default)
|
||||
language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-member-expression-this.js(strict mode)
|
||||
language/statements/for-in/dstr/array-rest-before-elision.js(default)
|
||||
language/statements/for-in/dstr/array-rest-before-elision.js(strict mode)
|
||||
language/statements/for-in/dstr/array-rest-elision-invalid.js(default)
|
||||
language/statements/for-in/dstr/array-rest-elision-invalid.js(strict mode)
|
||||
language/statements/for-of/dstr/array-rest-before-elision.js(default)
|
||||
language/statements/for-of/dstr/array-rest-before-elision.js(strict mode)
|
||||
language/statements/for-of/dstr/array-rest-elision-invalid.js(default)
|
||||
language/statements/for-of/dstr/array-rest-elision-invalid.js(strict mode)
|
||||
language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-member-expression-this.js(strict mode)
|
||||
Reference in New Issue
Block a user