Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e1d6e7ff4 | ||
|
|
efb71ea12b | ||
|
|
cbbb3c7962 | ||
|
|
4fcee1751a | ||
|
|
efa571a42c | ||
|
|
bf8c4785f2 | ||
|
|
4f206b2416 | ||
|
|
504b331da4 | ||
|
|
74f969b603 | ||
|
|
4dfd801887 | ||
|
|
62233ed7c9 | ||
|
|
7b54ab620b | ||
|
|
343f776ca5 | ||
|
|
756ded4d64 | ||
|
|
b706e34fc8 | ||
|
|
5d5cd8612f |
@@ -2542,7 +2542,7 @@ Also started Babel to compile itself with Babel 7! (We'll be working on making i
|
||||
|
||||
#### :nail_care: Polish
|
||||
* `babel-register`
|
||||
* [#5411](https://github.com/babel/babel/pull/5411) Seperate version env cache files. ([@pwmckenna](https://github.com/pwmckenna))
|
||||
* [#5411](https://github.com/babel/babel/pull/5411) Separate version env cache files. ([@pwmckenna](https://github.com/pwmckenna))
|
||||
|
||||
#### :memo: Documentation
|
||||
* `babel-plugin-transform-runtime`
|
||||
|
||||
2
Makefile
2
Makefile
@@ -125,7 +125,7 @@ prepublish:
|
||||
|
||||
publish: prepublish
|
||||
# --only-explicit-updates
|
||||
./node_modules/.bin/lerna publish
|
||||
./node_modules/.bin/lerna publish --force-publish="@babel/runtime,@babel/runtime-corejs2" --dangerously-only-publish-explicit-updates-this-is-a-custom-flag-for-babel-and-you-should-not-be-using-it-just-deal-with-more-packages-being-published-it-is-not-a-big-deal
|
||||
make clean
|
||||
|
||||
bootstrap: clean-all
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"lerna": "2.11.0",
|
||||
"version": "7.1.5",
|
||||
"version": "7.1.6",
|
||||
"changelog": {
|
||||
"repo": "babel/babel",
|
||||
"cacheDir": ".changelog",
|
||||
|
||||
@@ -2,12 +2,6 @@
|
||||
* Basic declarations for the npm modules we use.
|
||||
*/
|
||||
|
||||
declare module "micromatch" {
|
||||
declare module.exports: {
|
||||
(Array<string>, Array<string>, ?{ nocase: boolean }): Array<string>,
|
||||
};
|
||||
}
|
||||
|
||||
declare module "resolve" {
|
||||
declare export default {
|
||||
sync: (string, {| basedir: string |}) => string;
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
"lodash": "^4.17.10",
|
||||
"merge-stream": "^1.0.1",
|
||||
"output-file-sync": "^2.0.0",
|
||||
"prettier": "^1.14.3",
|
||||
"prettier": "^1.15.1",
|
||||
"pump": "^1.0.2",
|
||||
"rimraf": "^2.4.3",
|
||||
"rollup-plugin-babel": "^4.0.0-beta.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/core",
|
||||
"version": "7.1.5",
|
||||
"version": "7.1.6",
|
||||
"description": "Babel compiler core.",
|
||||
"main": "lib/index.js",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
@@ -34,15 +34,15 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.0.0",
|
||||
"@babel/generator": "^7.1.5",
|
||||
"@babel/generator": "^7.1.6",
|
||||
"@babel/helpers": "^7.1.5",
|
||||
"@babel/parser": "^7.1.5",
|
||||
"@babel/parser": "^7.1.6",
|
||||
"@babel/template": "^7.1.2",
|
||||
"@babel/traverse": "^7.1.5",
|
||||
"@babel/types": "^7.1.5",
|
||||
"@babel/traverse": "^7.1.6",
|
||||
"@babel/types": "^7.1.6",
|
||||
"convert-source-map": "^1.1.0",
|
||||
"debug": "^3.1.0",
|
||||
"json5": "^0.5.0",
|
||||
"debug": "^4.1.0",
|
||||
"json5": "^2.1.0",
|
||||
"lodash": "^4.17.10",
|
||||
"resolve": "^1.3.2",
|
||||
"semver": "^5.4.1",
|
||||
|
||||
@@ -1,14 +1,29 @@
|
||||
// @flow
|
||||
import type { FileResult } from "./transformation";
|
||||
|
||||
export default function transformFile(
|
||||
filename: string,
|
||||
opts?: Object = {},
|
||||
callback: (?Error, FileResult | null) => void,
|
||||
// duplicated from transform-file so we do not have to import anything here
|
||||
type TransformFile = {
|
||||
(filename: string, callback: Function): void,
|
||||
(filename: string, opts: ?Object, callback: Function): void,
|
||||
};
|
||||
|
||||
export const transformFile: TransformFile = (function transformFile(
|
||||
filename,
|
||||
opts,
|
||||
callback,
|
||||
) {
|
||||
if (typeof opts === "function") {
|
||||
callback = opts;
|
||||
}
|
||||
|
||||
callback(new Error("Transforming files is not supported in browsers"), null);
|
||||
}: Function);
|
||||
|
||||
export function transformFileSync() {
|
||||
throw new Error("Transforming files is not supported in browsers");
|
||||
}
|
||||
|
||||
export function transformFileAsync() {
|
||||
return Promise.reject(
|
||||
new Error("Transforming files is not supported in browsers"),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
// @flow
|
||||
|
||||
export default function transformFileSync() {
|
||||
throw new Error("Transforming files is not supported in browsers");
|
||||
}
|
||||
@@ -9,6 +9,14 @@ import {
|
||||
type FileResultCallback,
|
||||
} from "./transformation";
|
||||
|
||||
import typeof * as transformFileBrowserType from "./transform-file-browser";
|
||||
import typeof * as transformFileType from "./transform-file";
|
||||
|
||||
// Kind of gross, but essentially asserting that the exports of this module are the same as the
|
||||
// exports of transform-file-browser, since this file may be replaced at bundle time with
|
||||
// transform-file-browser.
|
||||
((({}: any): $Exact<transformFileBrowserType>): $Exact<transformFileType>);
|
||||
|
||||
type TransformFile = {
|
||||
(filename: string, callback: FileResultCallback): void,
|
||||
(filename: string, opts: ?InputOptions, callback: FileResultCallback): void,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/generator",
|
||||
"version": "7.1.5",
|
||||
"version": "7.1.6",
|
||||
"description": "Turns an AST into code.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -14,7 +14,7 @@
|
||||
"lib"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.1.5",
|
||||
"@babel/types": "^7.1.6",
|
||||
"jsesc": "^2.5.1",
|
||||
"lodash": "^4.17.10",
|
||||
"source-map": "^0.5.0",
|
||||
@@ -22,6 +22,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-fixtures": "^7.0.0",
|
||||
"@babel/parser": "^7.1.5"
|
||||
"@babel/parser": "^7.1.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,10 +113,12 @@ export function ArrowFunctionExpression(node: Object) {
|
||||
) {
|
||||
if (
|
||||
this.format.retainLines &&
|
||||
node.loc &&
|
||||
node.body.loc &&
|
||||
node.loc.start.line < node.body.loc.start.line
|
||||
) {
|
||||
this.token("(");
|
||||
if (firstParam.loc.start.line > node.loc.start.line) {
|
||||
if (firstParam.loc && firstParam.loc.start.line > node.loc.start.line) {
|
||||
this.indent();
|
||||
this.print(firstParam, node);
|
||||
this.dedent();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/parser",
|
||||
"version": "7.1.5",
|
||||
"version": "7.1.6",
|
||||
"description": "A JavaScript parser",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
|
||||
@@ -23,6 +23,7 @@ import * as N from "../types";
|
||||
import LValParser from "./lval";
|
||||
import { reservedWords } from "../util/identifier";
|
||||
import type { Pos, Position } from "../util/location";
|
||||
import * as charCodes from "charcodes";
|
||||
|
||||
export default class ExpressionParser extends LValParser {
|
||||
// Forward-declaration: defined in statement.js
|
||||
@@ -331,8 +332,8 @@ export default class ExpressionParser extends LValParser {
|
||||
this.finishNode(
|
||||
node,
|
||||
op === tt.logicalOR ||
|
||||
op === tt.logicalAND ||
|
||||
op === tt.nullishCoalescing
|
||||
op === tt.logicalAND ||
|
||||
op === tt.nullishCoalescing
|
||||
? "LogicalExpression"
|
||||
: "BinaryExpression",
|
||||
);
|
||||
@@ -718,6 +719,10 @@ export default class ExpressionParser extends LValParser {
|
||||
// or `{}`.
|
||||
|
||||
parseExprAtom(refShorthandDefaultPos?: ?Pos): N.Expression {
|
||||
// If a division operator appears in an expression position, the
|
||||
// tokenizer got confused, and we force it to read a regexp instead.
|
||||
if (this.state.type === tt.slash) this.readRegexp();
|
||||
|
||||
const canBeArrow = this.state.potentialArrowAt === this.state.start;
|
||||
let node;
|
||||
|
||||
@@ -964,7 +969,16 @@ export default class ExpressionParser extends LValParser {
|
||||
|
||||
parseFunctionExpression(): N.FunctionExpression | N.MetaProperty {
|
||||
const node = this.startNode();
|
||||
const meta = this.parseIdentifier(true);
|
||||
|
||||
// We do not do parseIdentifier here because when parseFunctionExpression
|
||||
// is called we already know that the current token is a "name" with the value "function"
|
||||
// This will improve perf a tiny little bit as we do not do validation but more importantly
|
||||
// here is that parseIdentifier will remove an item from the expression stack
|
||||
// if "function" or "class" is parsed as identifier (in objects e.g.), which should not happen here.
|
||||
let meta = this.startNode();
|
||||
this.next();
|
||||
meta = this.createIdentifier(meta, "function");
|
||||
|
||||
if (this.state.inGenerator && this.eat(tt.dot)) {
|
||||
return this.parseMetaProperty(node, meta, "sent");
|
||||
}
|
||||
@@ -1863,8 +1877,14 @@ export default class ExpressionParser extends LValParser {
|
||||
parseIdentifier(liberal?: boolean): N.Identifier {
|
||||
const node = this.startNode();
|
||||
const name = this.parseIdentifierName(node.start, liberal);
|
||||
|
||||
return this.createIdentifier(node, name);
|
||||
}
|
||||
|
||||
createIdentifier(node: N.Identifier, name: string): N.Identifier {
|
||||
node.name = name;
|
||||
node.loc.identifierName = name;
|
||||
|
||||
return this.finishNode(node, "Identifier");
|
||||
}
|
||||
|
||||
@@ -1884,6 +1904,19 @@ export default class ExpressionParser extends LValParser {
|
||||
name = this.state.value;
|
||||
} else if (this.state.type.keyword) {
|
||||
name = this.state.type.keyword;
|
||||
|
||||
// `class` and `function` keywords push new context into this.context.
|
||||
// But there is no chance to pop the context if the keyword is consumed
|
||||
// as an identifier such as a property name.
|
||||
// If the previous token is a dot, this does not apply because the
|
||||
// context-managing code already ignored the keyword
|
||||
if (
|
||||
(name === "class" || name === "function") &&
|
||||
(this.state.lastTokEnd !== this.state.lastTokStart + 1 ||
|
||||
this.input.charCodeAt(this.state.lastTokStart) !== charCodes.dot)
|
||||
) {
|
||||
this.state.context.pop();
|
||||
}
|
||||
} else {
|
||||
throw this.unexpected();
|
||||
}
|
||||
|
||||
@@ -619,8 +619,8 @@ export default class StatementParser extends ExpressionParser {
|
||||
const kind = this.state.type.isLoop
|
||||
? "loop"
|
||||
: this.match(tt._switch)
|
||||
? "switch"
|
||||
: null;
|
||||
? "switch"
|
||||
: null;
|
||||
for (let i = this.state.labels.length - 1; i >= 0; i--) {
|
||||
const label = this.state.labels[i];
|
||||
if (label.statementStart === node.start) {
|
||||
|
||||
@@ -6,10 +6,11 @@ import * as N from "../types";
|
||||
import type { Options } from "../options";
|
||||
import type { Pos, Position } from "../util/location";
|
||||
import type State from "../tokenizer/state";
|
||||
import { types as tc } from "../tokenizer/context";
|
||||
import * as charCodes from "charcodes";
|
||||
import { isIteratorStart } from "../util/identifier";
|
||||
|
||||
const primitiveTypes = [
|
||||
const reservedTypes = [
|
||||
"any",
|
||||
"bool",
|
||||
"boolean",
|
||||
@@ -503,8 +504,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
|
||||
checkReservedType(word: string, startLoc: number) {
|
||||
if (primitiveTypes.indexOf(word) > -1) {
|
||||
this.raise(startLoc, `Cannot overwrite primitive type ${word}`);
|
||||
if (reservedTypes.indexOf(word) > -1) {
|
||||
this.raise(startLoc, `Cannot overwrite reserved type ${word}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2392,7 +2393,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
refNeedsArrowPos?: ?Pos,
|
||||
): N.Expression {
|
||||
let jsxError = null;
|
||||
if (tt.jsxTagStart && this.match(tt.jsxTagStart)) {
|
||||
if (
|
||||
this.hasPlugin("jsx") &&
|
||||
(this.match(tt.jsxTagStart) || this.isRelational("<"))
|
||||
) {
|
||||
const state = this.state.clone();
|
||||
try {
|
||||
return super.parseMaybeAssign(
|
||||
@@ -2408,7 +2412,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
// Remove `tc.j_expr` and `tc.j_oTag` from context added
|
||||
// by parsing `jsxTagStart` to stop the JSX plugin from
|
||||
// messing with the tokens
|
||||
this.state.context.length -= 2;
|
||||
const cLength = this.state.context.length;
|
||||
if (this.state.context[cLength - 1] === tc.j_oTag) {
|
||||
this.state.context.length -= 2;
|
||||
}
|
||||
|
||||
jsxError = err;
|
||||
} else {
|
||||
|
||||
@@ -506,6 +506,15 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
return this.parseLiteral(this.state.value, "JSXText");
|
||||
} else if (this.match(tt.jsxTagStart)) {
|
||||
return this.jsxParseElement();
|
||||
} else if (
|
||||
this.isRelational("<") &&
|
||||
this.state.input.charCodeAt(this.state.pos) !==
|
||||
charCodes.exclamationMark
|
||||
) {
|
||||
// In case we encounter an lt token here it will always be the start of
|
||||
// jsx as the lt sign is not allowed in places that expect an expression
|
||||
this.finishToken(tt.jsxTagStart);
|
||||
return this.jsxParseElement();
|
||||
} else {
|
||||
return super.parseExprAtom(refShortHandDefaultPos);
|
||||
}
|
||||
@@ -538,7 +547,12 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
}
|
||||
|
||||
if (code === charCodes.lessThan && this.state.exprAllowed) {
|
||||
if (
|
||||
code === charCodes.lessThan &&
|
||||
this.state.exprAllowed &&
|
||||
this.state.input.charCodeAt(this.state.pos + 1) !==
|
||||
charCodes.exclamationMark
|
||||
) {
|
||||
++this.state.pos;
|
||||
return this.finishToken(tt.jsxTagStart);
|
||||
}
|
||||
|
||||
@@ -597,8 +597,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
const type = this.match(tt._void)
|
||||
? "TSVoidKeyword"
|
||||
: this.match(tt._null)
|
||||
? "TSNullKeyword"
|
||||
: keywordTypeFromName(this.state.value);
|
||||
? "TSNullKeyword"
|
||||
: keywordTypeFromName(this.state.value);
|
||||
if (type !== undefined && this.lookahead().type !== tt.dot) {
|
||||
const node: N.TsKeywordType = this.startNode();
|
||||
this.next();
|
||||
@@ -691,8 +691,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
return operator
|
||||
? this.tsParseTypeOperator(operator)
|
||||
: this.isContextual("infer")
|
||||
? this.tsParseInferType()
|
||||
: this.tsParseArrayTypeOrHigher();
|
||||
? this.tsParseInferType()
|
||||
: this.tsParseArrayTypeOrHigher();
|
||||
}
|
||||
|
||||
tsParseUnionOrIntersectionType(
|
||||
@@ -1381,8 +1381,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
type === "FunctionDeclaration"
|
||||
? "TSDeclareFunction"
|
||||
: type === "ClassMethod"
|
||||
? "TSDeclareMethod"
|
||||
: undefined;
|
||||
? "TSDeclareMethod"
|
||||
: undefined;
|
||||
if (bodilessType && !this.match(tt.braceL) && this.isLineTerminator()) {
|
||||
this.finishNode(node, bodilessType);
|
||||
return;
|
||||
|
||||
@@ -12,7 +12,7 @@ export class TokContext {
|
||||
token: string,
|
||||
isExpr?: boolean,
|
||||
preserveSpace?: boolean,
|
||||
override?: Function, // Takes a Tokenizer as a this-parameter, and returns void.
|
||||
override?: ?Function, // Takes a Tokenizer as a this-parameter, and returns void.
|
||||
) {
|
||||
this.token = token;
|
||||
this.isExpr = !!isExpr;
|
||||
@@ -31,11 +31,12 @@ export const types: {
|
||||
} = {
|
||||
braceStatement: new TokContext("{", false),
|
||||
braceExpression: new TokContext("{", true),
|
||||
templateQuasi: new TokContext("${", true),
|
||||
templateQuasi: new TokContext("${", false),
|
||||
parenStatement: new TokContext("(", false),
|
||||
parenExpression: new TokContext("(", true),
|
||||
template: new TokContext("`", true, true, p => p.readTmplToken()),
|
||||
functionExpression: new TokContext("function", true),
|
||||
functionStatement: new TokContext("function", false),
|
||||
};
|
||||
|
||||
// Token-specific context update code
|
||||
@@ -46,33 +47,26 @@ tt.parenR.updateContext = tt.braceR.updateContext = function() {
|
||||
return;
|
||||
}
|
||||
|
||||
const out = this.state.context.pop();
|
||||
if (
|
||||
out === types.braceStatement &&
|
||||
this.curContext() === types.functionExpression
|
||||
) {
|
||||
this.state.context.pop();
|
||||
this.state.exprAllowed = false;
|
||||
} else if (out === types.templateQuasi) {
|
||||
this.state.exprAllowed = true;
|
||||
} else {
|
||||
this.state.exprAllowed = !out.isExpr;
|
||||
let out = this.state.context.pop();
|
||||
if (out === types.braceStatement && this.curContext().token === "function") {
|
||||
out = this.state.context.pop();
|
||||
}
|
||||
|
||||
this.state.exprAllowed = !out.isExpr;
|
||||
};
|
||||
|
||||
tt.name.updateContext = function(prevType) {
|
||||
if (this.state.value === "of" && this.curContext() === types.parenStatement) {
|
||||
this.state.exprAllowed = !prevType.beforeExpr;
|
||||
return;
|
||||
}
|
||||
|
||||
this.state.exprAllowed = false;
|
||||
|
||||
if (prevType === tt._let || prevType === tt._const || prevType === tt._var) {
|
||||
if (lineBreak.test(this.input.slice(this.state.end))) {
|
||||
this.state.exprAllowed = true;
|
||||
let allowed = false;
|
||||
if (prevType !== tt.dot) {
|
||||
if (
|
||||
(this.state.value === "of" && !this.state.exprAllowed) ||
|
||||
(this.state.value === "yield" && this.state.inGenerator)
|
||||
) {
|
||||
allowed = true;
|
||||
}
|
||||
}
|
||||
this.state.exprAllowed = allowed;
|
||||
|
||||
if (this.state.isIterator) {
|
||||
this.state.isIterator = false;
|
||||
}
|
||||
@@ -107,8 +101,22 @@ tt.incDec.updateContext = function() {
|
||||
};
|
||||
|
||||
tt._function.updateContext = tt._class.updateContext = function(prevType) {
|
||||
if (this.state.exprAllowed && !this.braceIsBlock(prevType)) {
|
||||
if (
|
||||
prevType.beforeExpr &&
|
||||
prevType !== tt.semi &&
|
||||
prevType !== tt._else &&
|
||||
!(
|
||||
prevType === tt._return &&
|
||||
lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start))
|
||||
) &&
|
||||
!(
|
||||
(prevType === tt.colon || prevType === tt.braceL) &&
|
||||
this.curContext() === types.b_stat
|
||||
)
|
||||
) {
|
||||
this.state.context.push(types.functionExpression);
|
||||
} else {
|
||||
this.state.context.push(types.functionStatement);
|
||||
}
|
||||
|
||||
this.state.exprAllowed = false;
|
||||
|
||||
@@ -881,10 +881,10 @@ export default class Tokenizer extends LocationParser {
|
||||
radix === 16
|
||||
? allowedNumericSeparatorSiblings.hex
|
||||
: radix === 10
|
||||
? allowedNumericSeparatorSiblings.dec
|
||||
: radix === 8
|
||||
? allowedNumericSeparatorSiblings.oct
|
||||
: allowedNumericSeparatorSiblings.bin;
|
||||
? allowedNumericSeparatorSiblings.dec
|
||||
: radix === 8
|
||||
? allowedNumericSeparatorSiblings.oct
|
||||
: allowedNumericSeparatorSiblings.bin;
|
||||
|
||||
let total = 0;
|
||||
|
||||
@@ -1324,14 +1324,25 @@ export default class Tokenizer extends LocationParser {
|
||||
}
|
||||
|
||||
braceIsBlock(prevType: TokenType): boolean {
|
||||
if (prevType === tt.colon) {
|
||||
const parent = this.curContext();
|
||||
if (parent === ct.braceStatement || parent === ct.braceExpression) {
|
||||
return !parent.isExpr;
|
||||
}
|
||||
const parent = this.curContext();
|
||||
if (parent === ct.functionExpression || parent === ct.functionStatement) {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
prevType === tt.colon &&
|
||||
(parent === ct.braceStatement || parent === ct.braceExpression)
|
||||
) {
|
||||
return !parent.isExpr;
|
||||
}
|
||||
|
||||
if (prevType === tt._return) {
|
||||
// The check for `tt.name && exprAllowed` detects whether we are
|
||||
// after a `yield` or `of` construct. See the `updateContext` for
|
||||
// `tt.name`.
|
||||
if (
|
||||
prevType === tt._return ||
|
||||
prevType === tt._yield ||
|
||||
(prevType === tt.name && this.state.exprAllowed)
|
||||
) {
|
||||
return lineBreak.test(
|
||||
this.input.slice(this.state.lastTokEnd, this.state.start),
|
||||
);
|
||||
@@ -1341,13 +1352,22 @@ export default class Tokenizer extends LocationParser {
|
||||
prevType === tt._else ||
|
||||
prevType === tt.semi ||
|
||||
prevType === tt.eof ||
|
||||
prevType === tt.parenR
|
||||
prevType === tt.parenR ||
|
||||
prevType === tt.arrow
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (prevType === tt.braceL) {
|
||||
return this.curContext() === ct.braceStatement;
|
||||
return parent === ct.braceStatement;
|
||||
}
|
||||
|
||||
if (
|
||||
prevType === tt._var ||
|
||||
prevType === tt._let ||
|
||||
prevType === tt._const
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (prevType === tt.relational) {
|
||||
|
||||
@@ -174,7 +174,7 @@ export const keywords = {
|
||||
new: new KeywordTokenType("new", { beforeExpr, startsExpr }),
|
||||
this: new KeywordTokenType("this", { startsExpr }),
|
||||
super: new KeywordTokenType("super", { startsExpr }),
|
||||
class: new KeywordTokenType("class"),
|
||||
class: new KeywordTokenType("class", { startsExpr }),
|
||||
extends: new KeywordTokenType("extends", { beforeExpr }),
|
||||
export: new KeywordTokenType("export"),
|
||||
import: new KeywordTokenType("import", { startsExpr }),
|
||||
|
||||
1
packages/babel-parser/test/fixtures/es2015/for-of/brackets-const/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/es2015/for-of/brackets-const/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
for (const {a} of /b/) {}
|
||||
194
packages/babel-parser/test/fixtures/es2015/for-of/brackets-const/output.json
vendored
Normal file
194
packages/babel-parser/test/fixtures/es2015/for-of/brackets-const/output.json
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ForOfStatement",
|
||||
"start": 0,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
}
|
||||
},
|
||||
"await": false,
|
||||
"left": {
|
||||
"type": "VariableDeclaration",
|
||||
"start": 5,
|
||||
"end": 14,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
}
|
||||
},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start": 11,
|
||||
"end": 14,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "ObjectPattern",
|
||||
"start": 11,
|
||||
"end": 14,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
}
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start": 12,
|
||||
"end": 13,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 13
|
||||
}
|
||||
},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 12,
|
||||
"end": 13,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 13
|
||||
},
|
||||
"identifierName": "a"
|
||||
},
|
||||
"name": "a"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": true,
|
||||
"value": {
|
||||
"type": "Identifier",
|
||||
"start": 12,
|
||||
"end": 13,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 13
|
||||
},
|
||||
"identifierName": "a"
|
||||
},
|
||||
"name": "a"
|
||||
},
|
||||
"extra": {
|
||||
"shorthand": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"init": null
|
||||
}
|
||||
],
|
||||
"kind": "const"
|
||||
},
|
||||
"right": {
|
||||
"type": "RegExpLiteral",
|
||||
"start": 18,
|
||||
"end": 21,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 21
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"raw": "/b/"
|
||||
},
|
||||
"pattern": "b",
|
||||
"flags": ""
|
||||
},
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 23,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 25
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/es2015/for-of/brackets-let/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/es2015/for-of/brackets-let/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
for (let {a} of /b/) {}
|
||||
194
packages/babel-parser/test/fixtures/es2015/for-of/brackets-let/output.json
vendored
Normal file
194
packages/babel-parser/test/fixtures/es2015/for-of/brackets-let/output.json
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ForOfStatement",
|
||||
"start": 0,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"await": false,
|
||||
"left": {
|
||||
"type": "VariableDeclaration",
|
||||
"start": 5,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start": 9,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "ObjectPattern",
|
||||
"start": 9,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start": 10,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
}
|
||||
},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 10,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "a"
|
||||
},
|
||||
"name": "a"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": true,
|
||||
"value": {
|
||||
"type": "Identifier",
|
||||
"start": 10,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "a"
|
||||
},
|
||||
"name": "a"
|
||||
},
|
||||
"extra": {
|
||||
"shorthand": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"init": null
|
||||
}
|
||||
],
|
||||
"kind": "let"
|
||||
},
|
||||
"right": {
|
||||
"type": "RegExpLiteral",
|
||||
"start": 16,
|
||||
"end": 19,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 19
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"raw": "/b/"
|
||||
},
|
||||
"pattern": "b",
|
||||
"flags": ""
|
||||
},
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 21,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 21
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/es2015/for-of/brackets-var/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/es2015/for-of/brackets-var/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
for (var {a} of /b/) {}
|
||||
194
packages/babel-parser/test/fixtures/es2015/for-of/brackets-var/output.json
vendored
Normal file
194
packages/babel-parser/test/fixtures/es2015/for-of/brackets-var/output.json
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ForOfStatement",
|
||||
"start": 0,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"await": false,
|
||||
"left": {
|
||||
"type": "VariableDeclaration",
|
||||
"start": 5,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start": 9,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "ObjectPattern",
|
||||
"start": 9,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start": 10,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
}
|
||||
},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 10,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "a"
|
||||
},
|
||||
"name": "a"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": true,
|
||||
"value": {
|
||||
"type": "Identifier",
|
||||
"start": 10,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "a"
|
||||
},
|
||||
"name": "a"
|
||||
},
|
||||
"extra": {
|
||||
"shorthand": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"init": null
|
||||
}
|
||||
],
|
||||
"kind": "var"
|
||||
},
|
||||
"right": {
|
||||
"type": "RegExpLiteral",
|
||||
"start": 16,
|
||||
"end": 19,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 19
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"raw": "/b/"
|
||||
},
|
||||
"pattern": "b",
|
||||
"flags": ""
|
||||
},
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 21,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 21
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/es2015/yield/asi2/input.js
vendored
Normal file
3
packages/babel-parser/test/fixtures/es2015/yield/asi2/input.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
function *f() { yield
|
||||
{}/1/g
|
||||
}
|
||||
172
packages/babel-parser/test/fixtures/es2015/yield/asi2/output.json
vendored
Normal file
172
packages/babel-parser/test/fixtures/es2015/yield/asi2/output.json
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start": 0,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 10,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "f"
|
||||
},
|
||||
"name": "f"
|
||||
},
|
||||
"generator": true,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 14,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 16,
|
||||
"end": 21,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 21
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "YieldExpression",
|
||||
"start": 16,
|
||||
"end": 21,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 21
|
||||
}
|
||||
},
|
||||
"delegate": false,
|
||||
"argument": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "BlockStatement",
|
||||
"start": 22,
|
||||
"end": 24,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
},
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 24,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "RegExpLiteral",
|
||||
"start": 24,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"raw": "/1/g"
|
||||
},
|
||||
"pattern": "1",
|
||||
"flags": "g"
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/es2015/yield/yield class/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/es2015/yield/yield class/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
function* bar() { yield class {} }
|
||||
152
packages/babel-parser/test/fixtures/es2015/yield/yield class/output.json
vendored
Normal file
152
packages/babel-parser/test/fixtures/es2015/yield/yield class/output.json
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 34
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 34
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start": 0,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 34
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 10,
|
||||
"end": 13,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 13
|
||||
},
|
||||
"identifierName": "bar"
|
||||
},
|
||||
"name": "bar"
|
||||
},
|
||||
"generator": true,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 16,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 34
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 18,
|
||||
"end": 32,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "YieldExpression",
|
||||
"start": 18,
|
||||
"end": 32,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"delegate": false,
|
||||
"argument": {
|
||||
"type": "ClassExpression",
|
||||
"start": 24,
|
||||
"end": 32,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 24
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"id": null,
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 30,
|
||||
"end": 32,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 30
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"body": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Cannot overwrite primitive type string (1:10)"
|
||||
"throws": "Cannot overwrite reserved type string (1:10)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Cannot overwrite primitive type string (1:21)"
|
||||
"throws": "Cannot overwrite reserved type string (1:21)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Cannot overwrite primitive type string (1:12)"
|
||||
"throws": "Cannot overwrite reserved type string (1:12)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Cannot overwrite primitive type number (1:5)"
|
||||
"throws": "Cannot overwrite reserved type number (1:5)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Cannot overwrite primitive type number (1:9)"
|
||||
"throws": "Cannot overwrite reserved type number (1:9)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Cannot overwrite primitive type string (1:11)"
|
||||
"throws": "Cannot overwrite reserved type string (1:11)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Cannot overwrite primitive type bool (1:13)"
|
||||
"throws": "Cannot overwrite reserved type bool (1:13)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Cannot overwrite primitive type string (1:14)"
|
||||
"throws": "Cannot overwrite reserved type string (1:14)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Cannot overwrite primitive type string (1:14)"
|
||||
"throws": "Cannot overwrite reserved type string (1:14)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Cannot overwrite primitive type string (1:19)"
|
||||
"throws": "Cannot overwrite reserved type string (1:19)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Cannot overwrite primitive type string (1:16)"
|
||||
"throws": "Cannot overwrite reserved type string (1:16)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Cannot overwrite primitive type string (1:14)"
|
||||
"throws": "Cannot overwrite reserved type string (1:14)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Cannot overwrite primitive type string (1:12)"
|
||||
"throws": "Cannot overwrite reserved type string (1:12)"
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
{
|
||||
"sourceType": "module",
|
||||
"plugins": [
|
||||
"jsx",
|
||||
"flow"
|
||||
],
|
||||
"throws": "Cannot overwrite primitive type _ (2:5)"
|
||||
}
|
||||
"plugins": ["jsx", "flow"],
|
||||
"throws": "Cannot overwrite reserved type _ (2:5)"
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
{
|
||||
"sourceType": "module",
|
||||
"plugins": [
|
||||
"jsx",
|
||||
"flow"
|
||||
],
|
||||
"throws": "Cannot overwrite primitive type _ (2:13)"
|
||||
}
|
||||
"plugins": ["jsx", "flow"],
|
||||
"throws": "Cannot overwrite reserved type _ (2:13)"
|
||||
}
|
||||
|
||||
1
packages/babel-parser/test/fixtures/jsx/errors/html-comment/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/jsx/errors/html-comment/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<!--a
|
||||
4
packages/babel-parser/test/fixtures/jsx/errors/html-comment/options.json
vendored
Normal file
4
packages/babel-parser/test/fixtures/jsx/errors/html-comment/options.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"sourceType": "script",
|
||||
"plugins": ["jsx", "flow"]
|
||||
}
|
||||
70
packages/babel-parser/test/fixtures/jsx/errors/html-comment/output.json
vendored
Normal file
70
packages/babel-parser/test/fixtures/jsx/errors/html-comment/output.json
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 5,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 5
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 5,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 5
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [],
|
||||
"directives": [],
|
||||
"innerComments": [
|
||||
{
|
||||
"type": "CommentLine",
|
||||
"value": "a",
|
||||
"start": 0,
|
||||
"end": 5,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 5
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"comments": [
|
||||
{
|
||||
"type": "CommentLine",
|
||||
"value": "a",
|
||||
"start": 0,
|
||||
"end": 5,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 5
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
6
packages/babel-parser/test/fixtures/jsx/regression/issue-8891/input.js
vendored
Normal file
6
packages/babel-parser/test/fixtures/jsx/regression/issue-8891/input.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<>
|
||||
<Select prop={{ function: 'test' }} />
|
||||
<Select prop={{ class: 'test' }} />
|
||||
<Select prop={{ delete: 'test' }} />
|
||||
<Select prop={{ enum: 'test' }} />
|
||||
</>
|
||||
873
packages/babel-parser/test/fixtures/jsx/regression/issue-8891/output.json
vendored
Normal file
873
packages/babel-parser/test/fixtures/jsx/regression/issue-8891/output.json
vendored
Normal file
@@ -0,0 +1,873 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 153,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 3
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 153,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 3
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 0,
|
||||
"end": 153,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 3
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "JSXFragment",
|
||||
"start": 0,
|
||||
"end": 153,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 3
|
||||
}
|
||||
},
|
||||
"openingFragment": {
|
||||
"type": "JSXOpeningFragment",
|
||||
"start": 0,
|
||||
"end": 2,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
"closingFragment": {
|
||||
"type": "JSXClosingFragment",
|
||||
"start": 150,
|
||||
"end": 153,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 6,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "JSXText",
|
||||
"start": 2,
|
||||
"end": 3,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "\n",
|
||||
"raw": "\n"
|
||||
},
|
||||
"value": "\n"
|
||||
},
|
||||
{
|
||||
"type": "JSXElement",
|
||||
"start": 3,
|
||||
"end": 41,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 38
|
||||
}
|
||||
},
|
||||
"openingElement": {
|
||||
"type": "JSXOpeningElement",
|
||||
"start": 3,
|
||||
"end": 41,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 38
|
||||
}
|
||||
},
|
||||
"name": {
|
||||
"type": "JSXIdentifier",
|
||||
"start": 4,
|
||||
"end": 10,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 7
|
||||
}
|
||||
},
|
||||
"name": "Select"
|
||||
},
|
||||
"attributes": [
|
||||
{
|
||||
"type": "JSXAttribute",
|
||||
"start": 11,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 35
|
||||
}
|
||||
},
|
||||
"name": {
|
||||
"type": "JSXIdentifier",
|
||||
"start": 11,
|
||||
"end": 15,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"name": "prop"
|
||||
},
|
||||
"value": {
|
||||
"type": "JSXExpressionContainer",
|
||||
"start": 16,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 13
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 35
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "ObjectExpression",
|
||||
"start": 17,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 34
|
||||
}
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start": 19,
|
||||
"end": 35,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 19,
|
||||
"end": 27,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 24
|
||||
},
|
||||
"identifierName": "function"
|
||||
},
|
||||
"name": "function"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": false,
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
"start": 29,
|
||||
"end": 35,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 26
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "test",
|
||||
"raw": "'test'"
|
||||
},
|
||||
"value": "test"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"selfClosing": true
|
||||
},
|
||||
"closingElement": null,
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"type": "JSXText",
|
||||
"start": 41,
|
||||
"end": 42,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 38
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 0
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "\n",
|
||||
"raw": "\n"
|
||||
},
|
||||
"value": "\n"
|
||||
},
|
||||
{
|
||||
"type": "JSXElement",
|
||||
"start": 42,
|
||||
"end": 77,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 35
|
||||
}
|
||||
},
|
||||
"openingElement": {
|
||||
"type": "JSXOpeningElement",
|
||||
"start": 42,
|
||||
"end": 77,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 35
|
||||
}
|
||||
},
|
||||
"name": {
|
||||
"type": "JSXIdentifier",
|
||||
"start": 43,
|
||||
"end": 49,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 7
|
||||
}
|
||||
},
|
||||
"name": "Select"
|
||||
},
|
||||
"attributes": [
|
||||
{
|
||||
"type": "JSXAttribute",
|
||||
"start": 50,
|
||||
"end": 74,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"name": {
|
||||
"type": "JSXIdentifier",
|
||||
"start": 50,
|
||||
"end": 54,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"name": "prop"
|
||||
},
|
||||
"value": {
|
||||
"type": "JSXExpressionContainer",
|
||||
"start": 55,
|
||||
"end": 74,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 13
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "ObjectExpression",
|
||||
"start": 56,
|
||||
"end": 73,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 31
|
||||
}
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start": 58,
|
||||
"end": 71,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 29
|
||||
}
|
||||
},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 58,
|
||||
"end": 63,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 21
|
||||
},
|
||||
"identifierName": "class"
|
||||
},
|
||||
"name": "class"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": false,
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
"start": 65,
|
||||
"end": 71,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 23
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 29
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "test",
|
||||
"raw": "'test'"
|
||||
},
|
||||
"value": "test"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"selfClosing": true
|
||||
},
|
||||
"closingElement": null,
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"type": "JSXText",
|
||||
"start": 77,
|
||||
"end": 78,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 35
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 0
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "\n",
|
||||
"raw": "\n"
|
||||
},
|
||||
"value": "\n"
|
||||
},
|
||||
{
|
||||
"type": "JSXElement",
|
||||
"start": 78,
|
||||
"end": 114,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 36
|
||||
}
|
||||
},
|
||||
"openingElement": {
|
||||
"type": "JSXOpeningElement",
|
||||
"start": 78,
|
||||
"end": 114,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 36
|
||||
}
|
||||
},
|
||||
"name": {
|
||||
"type": "JSXIdentifier",
|
||||
"start": 79,
|
||||
"end": 85,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 7
|
||||
}
|
||||
},
|
||||
"name": "Select"
|
||||
},
|
||||
"attributes": [
|
||||
{
|
||||
"type": "JSXAttribute",
|
||||
"start": 86,
|
||||
"end": 111,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 33
|
||||
}
|
||||
},
|
||||
"name": {
|
||||
"type": "JSXIdentifier",
|
||||
"start": 86,
|
||||
"end": 90,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"name": "prop"
|
||||
},
|
||||
"value": {
|
||||
"type": "JSXExpressionContainer",
|
||||
"start": 91,
|
||||
"end": 111,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 13
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 33
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "ObjectExpression",
|
||||
"start": 92,
|
||||
"end": 110,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start": 94,
|
||||
"end": 108,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 30
|
||||
}
|
||||
},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 94,
|
||||
"end": 100,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 22
|
||||
},
|
||||
"identifierName": "delete"
|
||||
},
|
||||
"name": "delete"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": false,
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
"start": 102,
|
||||
"end": 108,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 24
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 30
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "test",
|
||||
"raw": "'test'"
|
||||
},
|
||||
"value": "test"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"selfClosing": true
|
||||
},
|
||||
"closingElement": null,
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"type": "JSXText",
|
||||
"start": 114,
|
||||
"end": 115,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 36
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 0
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "\n",
|
||||
"raw": "\n"
|
||||
},
|
||||
"value": "\n"
|
||||
},
|
||||
{
|
||||
"type": "JSXElement",
|
||||
"start": 115,
|
||||
"end": 149,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 34
|
||||
}
|
||||
},
|
||||
"openingElement": {
|
||||
"type": "JSXOpeningElement",
|
||||
"start": 115,
|
||||
"end": 149,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 34
|
||||
}
|
||||
},
|
||||
"name": {
|
||||
"type": "JSXIdentifier",
|
||||
"start": 116,
|
||||
"end": 122,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 7
|
||||
}
|
||||
},
|
||||
"name": "Select"
|
||||
},
|
||||
"attributes": [
|
||||
{
|
||||
"type": "JSXAttribute",
|
||||
"start": 123,
|
||||
"end": 146,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 31
|
||||
}
|
||||
},
|
||||
"name": {
|
||||
"type": "JSXIdentifier",
|
||||
"start": 123,
|
||||
"end": 127,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"name": "prop"
|
||||
},
|
||||
"value": {
|
||||
"type": "JSXExpressionContainer",
|
||||
"start": 128,
|
||||
"end": 146,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 13
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 31
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "ObjectExpression",
|
||||
"start": 129,
|
||||
"end": 145,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 30
|
||||
}
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start": 131,
|
||||
"end": 143,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 131,
|
||||
"end": 135,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 20
|
||||
},
|
||||
"identifierName": "enum"
|
||||
},
|
||||
"name": "enum"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": false,
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
"start": 137,
|
||||
"end": 143,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 22
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "test",
|
||||
"raw": "'test'"
|
||||
},
|
||||
"value": "test"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"selfClosing": true
|
||||
},
|
||||
"closingElement": null,
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"type": "JSXText",
|
||||
"start": 149,
|
||||
"end": 150,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 34
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 0
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "\n",
|
||||
"raw": "\n"
|
||||
},
|
||||
"value": "\n"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
{
|
||||
"plugins": [
|
||||
"typescript",
|
||||
["decorators", { "decoratorsBeforeExport": true }]
|
||||
],
|
||||
"plugins": ["typescript", ["decorators", { "decoratorsBeforeExport": true }]],
|
||||
"throws": "Unexpected token, expected \"(\" (2:0)"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
{
|
||||
"plugins": [
|
||||
"typescript",
|
||||
["decorators", { "decoratorsBeforeExport": true }]
|
||||
]
|
||||
"plugins": ["typescript", ["decorators", { "decoratorsBeforeExport": true }]]
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
{
|
||||
"sourceType": "module",
|
||||
"plugins": [
|
||||
"typescript"
|
||||
],
|
||||
"plugins": ["typescript"],
|
||||
"throws": "A required element cannot follow an optional element. (1:17)"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
{
|
||||
"sourceType": "module",
|
||||
"plugins": [
|
||||
"typescript"
|
||||
],
|
||||
"plugins": ["typescript"],
|
||||
"throws": "A rest element must be last in a tuple type. (1:8)"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/plugin-proposal-decorators",
|
||||
"version": "7.1.2",
|
||||
"version": "7.1.6",
|
||||
"author": "Logan Smyth <loganfsmyth@gmail.com>",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
@@ -24,7 +24,7 @@
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.0.0",
|
||||
"@babel/core": "^7.1.6",
|
||||
"@babel/helper-plugin-test-runner": "^7.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,8 +82,8 @@ function getSingleElementDefinition(path, superRef, classRef, file) {
|
||||
isMethod
|
||||
? value(node.body, node.params, node.async, node.generator)
|
||||
: node.value
|
||||
? value(template.ast`{ return ${node.value} }`)
|
||||
: prop("value", scope.buildUndefinedNode()),
|
||||
? value(template.ast`{ return ${node.value} }`)
|
||||
: prop("value", scope.buildUndefinedNode()),
|
||||
].filter(Boolean);
|
||||
|
||||
return t.objectExpression(properties);
|
||||
@@ -113,6 +113,10 @@ const bareSupersVisitor = {
|
||||
CallExpression(path, { initializeInstanceElements }) {
|
||||
if (path.get("callee").isSuper()) {
|
||||
path.insertAfter(t.cloneNode(initializeInstanceElements));
|
||||
|
||||
// Sometimes this path gets requeued (e.g. in (super(), foo)), and
|
||||
// it leads to infinite recursion.
|
||||
path.skip();
|
||||
}
|
||||
},
|
||||
Function(path) {
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
@decorator(parameter)
|
||||
class Sub extends Super {
|
||||
constructor() {
|
||||
super().method();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
let Sub = babelHelpers.decorate([decorator(parameter)], function (_initialize, _Super) {
|
||||
"use strict";
|
||||
|
||||
class Sub extends _Super {
|
||||
constructor() {
|
||||
var _temp;
|
||||
|
||||
(_temp = super(), _initialize(this), _temp).method();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
F: Sub,
|
||||
d: []
|
||||
};
|
||||
}, Super);
|
||||
@@ -0,0 +1,7 @@
|
||||
@dec
|
||||
class B extends A {
|
||||
constructor() {
|
||||
super();
|
||||
[];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
let B = babelHelpers.decorate([dec], function (_initialize, _A) {
|
||||
"use strict";
|
||||
|
||||
class B extends _A {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
_initialize(this);
|
||||
|
||||
[];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
F: B,
|
||||
d: []
|
||||
};
|
||||
}, A);
|
||||
@@ -0,0 +1,6 @@
|
||||
@dec
|
||||
class B extends A {
|
||||
constructor() {
|
||||
(0, super());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
let B = babelHelpers.decorate([dec], function (_initialize, _A) {
|
||||
"use strict";
|
||||
|
||||
class B extends _A {
|
||||
constructor() {
|
||||
var _temp;
|
||||
|
||||
0, (_temp = super(), _initialize(this), _temp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
F: B,
|
||||
d: []
|
||||
};
|
||||
}, A);
|
||||
@@ -0,0 +1,14 @@
|
||||
@dec
|
||||
class B extends A {
|
||||
constructor() {
|
||||
const foo = () => { super(); };
|
||||
|
||||
if (a) { super(); }
|
||||
else { foo(); }
|
||||
|
||||
while (0) { super(); }
|
||||
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
let B = babelHelpers.decorate([dec], function (_initialize, _A) {
|
||||
"use strict";
|
||||
|
||||
class B extends _A {
|
||||
constructor() {
|
||||
const foo = () => {
|
||||
super();
|
||||
|
||||
_initialize(this);
|
||||
};
|
||||
|
||||
if (a) {
|
||||
super();
|
||||
|
||||
_initialize(this);
|
||||
} else {
|
||||
foo();
|
||||
}
|
||||
|
||||
while (0) {
|
||||
super();
|
||||
|
||||
_initialize(this);
|
||||
}
|
||||
|
||||
super();
|
||||
|
||||
_initialize(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
F: B,
|
||||
d: []
|
||||
};
|
||||
}, A);
|
||||
@@ -0,0 +1,6 @@
|
||||
@dec
|
||||
class B extends A {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
let B = babelHelpers.decorate([dec], function (_initialize, _A) {
|
||||
"use strict";
|
||||
|
||||
class B extends _A {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
_initialize(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
F: B,
|
||||
d: []
|
||||
};
|
||||
}, A);
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/plugin-transform-flow-strip-types",
|
||||
"version": "7.0.0",
|
||||
"version": "7.1.6",
|
||||
"description": "Strip flow type annotations from your output code.",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-flow-strip-types",
|
||||
"license": "MIT",
|
||||
@@ -19,7 +19,7 @@
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.0.0",
|
||||
"@babel/core": "^7.1.6",
|
||||
"@babel/helper-plugin-test-runner": "^7.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,15 +25,19 @@ export default declare(api => {
|
||||
skipStrip = false;
|
||||
let directiveFound = false;
|
||||
|
||||
for (const comment of (comments: Array<Object>)) {
|
||||
if (comment.value.indexOf(FLOW_DIRECTIVE) >= 0) {
|
||||
directiveFound = true;
|
||||
if (comments) {
|
||||
for (const comment of (comments: Array<Object>)) {
|
||||
if (comment.value.indexOf(FLOW_DIRECTIVE) >= 0) {
|
||||
directiveFound = true;
|
||||
|
||||
// remove flow directive
|
||||
comment.value = comment.value.replace(FLOW_DIRECTIVE, "");
|
||||
// remove flow directive
|
||||
comment.value = comment.value.replace(FLOW_DIRECTIVE, "");
|
||||
|
||||
// remove the comment completely if it only consists of whitespace and/or stars
|
||||
if (!comment.value.replace(/\*/g, "").trim()) comment.ignore = true;
|
||||
// remove the comment completely if it only consists of whitespace and/or stars
|
||||
if (!comment.value.replace(/\*/g, "").trim()) {
|
||||
comment.ignore = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/plugin-transform-react-jsx",
|
||||
"version": "7.0.0",
|
||||
"version": "7.1.6",
|
||||
"description": "Turn JSX into React function calls",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-react-jsx",
|
||||
"license": "MIT",
|
||||
@@ -20,7 +20,7 @@
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.0.0",
|
||||
"@babel/core": "^7.1.6",
|
||||
"@babel/helper-plugin-test-runner": "^7.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,16 +51,18 @@ export default declare((api, options) => {
|
||||
let pragmaSet = !!options.pragma;
|
||||
let pragmaFragSet = !!options.pragmaFrag;
|
||||
|
||||
for (const comment of (file.ast.comments: Array<Object>)) {
|
||||
const jsxMatches = JSX_ANNOTATION_REGEX.exec(comment.value);
|
||||
if (jsxMatches) {
|
||||
pragma = jsxMatches[1];
|
||||
pragmaSet = true;
|
||||
}
|
||||
const jsxFragMatches = JSX_FRAG_ANNOTATION_REGEX.exec(comment.value);
|
||||
if (jsxFragMatches) {
|
||||
pragmaFrag = jsxFragMatches[1];
|
||||
pragmaFragSet = true;
|
||||
if (file.ast.comments) {
|
||||
for (const comment of (file.ast.comments: Array<Object>)) {
|
||||
const jsxMatches = JSX_ANNOTATION_REGEX.exec(comment.value);
|
||||
if (jsxMatches) {
|
||||
pragma = jsxMatches[1];
|
||||
pragmaSet = true;
|
||||
}
|
||||
const jsxFragMatches = JSX_FRAG_ANNOTATION_REGEX.exec(comment.value);
|
||||
if (jsxFragMatches) {
|
||||
pragmaFrag = jsxFragMatches[1];
|
||||
pragmaFragSet = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/preset-env",
|
||||
"version": "7.1.5",
|
||||
"version": "7.1.6",
|
||||
"description": "A Babel preset for each environment.",
|
||||
"author": "Henry Zhu <hi@henryzoo.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -61,7 +61,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.1.5",
|
||||
"@babel/core": "^7.1.5",
|
||||
"@babel/core": "^7.1.6",
|
||||
"@babel/helper-fixtures": "^7.0.0",
|
||||
"@babel/helper-plugin-test-runner": "^7.0.0",
|
||||
"caniuse-db": "1.0.30000851",
|
||||
|
||||
@@ -229,13 +229,15 @@ const getLowestImplementedVersion = ({ features }, env) => {
|
||||
return null;
|
||||
}
|
||||
|
||||
return envTests.map(str => str.replace(env, "")).reduce((a, b) => {
|
||||
if (b === unreleasedLabelForEnv) {
|
||||
return b;
|
||||
}
|
||||
return envTests
|
||||
.map(str => str.replace(env, ""))
|
||||
.reduce((a, b) => {
|
||||
if (b === unreleasedLabelForEnv) {
|
||||
return b;
|
||||
}
|
||||
|
||||
return semver.lt(semver.coerce(a), semver.coerce(b)) ? b : a;
|
||||
});
|
||||
return semver.lt(semver.coerce(a), semver.coerce(b)) ? b : a;
|
||||
});
|
||||
};
|
||||
|
||||
const generateData = (environments, features) => {
|
||||
|
||||
@@ -30,15 +30,16 @@ const validateTargetNames = (validTargets, targets) => {
|
||||
};
|
||||
|
||||
const browserNameMap = {
|
||||
and_chr: "chrome",
|
||||
android: "android",
|
||||
chrome: "chrome",
|
||||
and_chr: "chrome",
|
||||
edge: "edge",
|
||||
firefox: "firefox",
|
||||
ie: "ie",
|
||||
ios_saf: "ios",
|
||||
safari: "safari",
|
||||
node: "node",
|
||||
opera: "opera",
|
||||
safari: "safari",
|
||||
};
|
||||
|
||||
export const isBrowsersQueryValid = (
|
||||
|
||||
@@ -99,11 +99,12 @@ describe("getTargets", () => {
|
||||
it("works with current node version and string type browsers", () => {
|
||||
expect(
|
||||
getTargets({
|
||||
browsers: "current node, chrome 55",
|
||||
browsers: "current node, chrome 55, opera 42",
|
||||
}),
|
||||
).toEqual({
|
||||
node: process.versions.node,
|
||||
chrome: "55.0.0",
|
||||
opera: "42.0.0",
|
||||
});
|
||||
});
|
||||
|
||||
@@ -178,6 +179,7 @@ describe("getTargets", () => {
|
||||
chrome: "61.0.0",
|
||||
safari: "10.1.0",
|
||||
firefox: "60.0.0",
|
||||
opera: "48.0.0",
|
||||
ios: "10.3.0",
|
||||
edge: "16.0.0",
|
||||
});
|
||||
@@ -193,6 +195,7 @@ describe("getTargets", () => {
|
||||
chrome: "61.0.0",
|
||||
safari: "10.1.0",
|
||||
firefox: "60.0.0",
|
||||
opera: "48.0.0",
|
||||
ios: "10.3.0",
|
||||
edge: "16.0.0",
|
||||
});
|
||||
@@ -208,6 +211,7 @@ describe("getTargets", () => {
|
||||
chrome: "61.0.0",
|
||||
safari: "10.1.0",
|
||||
firefox: "60.0.0",
|
||||
opera: "48.0.0",
|
||||
ios: "10.3.0",
|
||||
ie: "11.0.0",
|
||||
edge: "16.0.0",
|
||||
@@ -228,6 +232,7 @@ describe("getTargets", () => {
|
||||
ie: "11.0.0",
|
||||
edge: "16.0.0",
|
||||
firefox: "60.0.0",
|
||||
opera: "48.0.0",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/traverse",
|
||||
"version": "7.1.5",
|
||||
"version": "7.1.6",
|
||||
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -12,12 +12,12 @@
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.0.0",
|
||||
"@babel/generator": "^7.1.5",
|
||||
"@babel/generator": "^7.1.6",
|
||||
"@babel/helper-function-name": "^7.1.0",
|
||||
"@babel/helper-split-export-declaration": "^7.0.0",
|
||||
"@babel/parser": "^7.1.5",
|
||||
"@babel/types": "^7.1.5",
|
||||
"debug": "^3.1.0",
|
||||
"@babel/parser": "^7.1.6",
|
||||
"@babel/types": "^7.1.6",
|
||||
"debug": "^4.1.0",
|
||||
"globals": "^11.1.0",
|
||||
"lodash": "^4.17.10"
|
||||
},
|
||||
|
||||
@@ -105,7 +105,17 @@ export function insertAfter(nodes) {
|
||||
parentPath.isExportNamedDeclaration() ||
|
||||
(parentPath.isExportDefaultDeclaration() && this.isDeclaration())
|
||||
) {
|
||||
return parentPath.insertAfter(nodes);
|
||||
return parentPath.insertAfter(
|
||||
nodes.map(node => {
|
||||
// Usually after an expression we can safely insert another expression:
|
||||
// A.insertAfter(B)
|
||||
// foo = A; -> foo = (A, B);
|
||||
// If A is an expression statement, it isn't safe anymore so we need to
|
||||
// convert B to an expression statement
|
||||
// A; -> A; B // No semicolon! It could break if followed by [!
|
||||
return t.isExpression(node) ? t.expressionStatement(node) : node;
|
||||
}),
|
||||
);
|
||||
} else if (
|
||||
(this.isNodeType("Expression") && !this.isJSXElement()) ||
|
||||
(parentPath.isForStatement() && this.key === "init")
|
||||
|
||||
@@ -235,7 +235,9 @@ describe("modification", function() {
|
||||
fnPath.insertAfter(t.identifier("x"));
|
||||
|
||||
expect(bodyPath.get("body")).toHaveLength(2);
|
||||
expect(bodyPath.get("body.1").node).toEqual(t.identifier("x"));
|
||||
expect(bodyPath.get("body.1").node).toEqual(
|
||||
t.expressionStatement(t.identifier("x")),
|
||||
);
|
||||
});
|
||||
|
||||
it("the ExportDefaultDeclaration, if a declaration is exported", function() {
|
||||
@@ -246,7 +248,9 @@ describe("modification", function() {
|
||||
fnPath.insertAfter(t.identifier("x"));
|
||||
|
||||
expect(bodyPath.get("body")).toHaveLength(2);
|
||||
expect(bodyPath.get("body.1").node).toEqual(t.identifier("x"));
|
||||
expect(bodyPath.get("body.1").node).toEqual(
|
||||
t.expressionStatement(t.identifier("x")),
|
||||
);
|
||||
});
|
||||
|
||||
it("the exported expression", function() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/types",
|
||||
"version": "7.1.5",
|
||||
"version": "7.1.6",
|
||||
"description": "Babel Types is a Lodash-esque utility library for AST nodes",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -14,7 +14,7 @@
|
||||
"to-fast-properties": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/generator": "^7.1.5",
|
||||
"@babel/parser": "^7.1.5"
|
||||
"@babel/generator": "^7.1.6",
|
||||
"@babel/parser": "^7.1.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,12 @@ export default function cloneNode<T: Object>(node: T, deep: boolean = true): T {
|
||||
// Special-case identifiers since they are the most cloned nodes.
|
||||
if (type === "Identifier") {
|
||||
newNode.name = node.name;
|
||||
|
||||
if (has(node, "typeAnnotation")) {
|
||||
newNode.typeAnnotation = deep
|
||||
? cloneIfNodeOrArray(node.typeAnnotation, true)
|
||||
: node.typeAnnotation;
|
||||
}
|
||||
} else if (!has(NODE_FIELDS, type)) {
|
||||
throw new Error(`Unknown node type: "${type}"`);
|
||||
} else {
|
||||
|
||||
@@ -56,4 +56,20 @@ describe("cloneNode", function() {
|
||||
expect(node.object).toBe(cloned.object);
|
||||
expect(node.property).toBe(cloned.property);
|
||||
});
|
||||
|
||||
it("should preserve type annotations", function() {
|
||||
const node = t.variableDeclaration("let", [
|
||||
t.variableDeclarator({
|
||||
...t.identifier("value"),
|
||||
typeAnnotation: t.anyTypeAnnotation(),
|
||||
}),
|
||||
]);
|
||||
const cloned = t.cloneNode(node, /* deep */ true);
|
||||
expect(cloned.declarations[0].id.typeAnnotation).toEqual(
|
||||
node.declarations[0].id.typeAnnotation,
|
||||
);
|
||||
expect(cloned.declarations[0].id.typeAnnotation).not.toBe(
|
||||
node.declarations[0].id.typeAnnotation,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:8)"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "invalid use of await inside of an async function (1:16)"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "invalid use of await inside of an async function (2:11)"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "await is not allowed in the parameters of an arrow function inside an async function (2:23)"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token, expected \",\" (1:17)"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "await is not allowed in the parameters of an arrow function inside an async function (2:7)"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "await is not allowed in the parameters of an arrow function inside an async function (2:13)"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token, expected \",\" (2:25)"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "await is not allowed in async function parameters (1:22)"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@ declare class ${NODE_PREFIX}Comment {
|
||||
loc: ${NODE_PREFIX}SourceLocation;
|
||||
}
|
||||
|
||||
declare class ${NODE_PREFIX}BlockComment extends ${NODE_PREFIX}Comment {
|
||||
type: "BlockComment";
|
||||
declare class ${NODE_PREFIX}CommentBlock extends ${NODE_PREFIX}Comment {
|
||||
type: "CommentBlock";
|
||||
}
|
||||
|
||||
declare class ${NODE_PREFIX}LineComment extends ${NODE_PREFIX}Comment {
|
||||
type: "LineComment";
|
||||
declare class ${NODE_PREFIX}CommentLine extends ${NODE_PREFIX}Comment {
|
||||
type: "CommentLine";
|
||||
}
|
||||
|
||||
declare class ${NODE_PREFIX}SourceLocation {
|
||||
|
||||
@@ -11,18 +11,18 @@ interface BaseComment {
|
||||
start: number;
|
||||
end: number;
|
||||
loc: SourceLocation;
|
||||
type: "BlockComment" | "LineComment";
|
||||
type: "CommentBlock" | "CommentLine";
|
||||
}
|
||||
|
||||
export interface BlockComment extends BaseComment {
|
||||
type: "BlockComment";
|
||||
export interface CommentBlock extends BaseComment {
|
||||
type: "CommentBlock";
|
||||
}
|
||||
|
||||
export interface LineComment extends BaseComment {
|
||||
type: "LineComment";
|
||||
export interface CommentLine extends BaseComment {
|
||||
type: "CommentLine";
|
||||
}
|
||||
|
||||
export type Comment = BlockComment | LineComment;
|
||||
export type Comment = CommentBlock | CommentLine;
|
||||
|
||||
export interface SourceLocation {
|
||||
start: {
|
||||
|
||||
@@ -7734,10 +7734,10 @@ preserve@^0.2.0:
|
||||
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
|
||||
integrity sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=
|
||||
|
||||
prettier@^1.14.3:
|
||||
version "1.14.3"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.14.3.tgz#90238dd4c0684b7edce5f83b0fb7328e48bd0895"
|
||||
integrity sha512-qZDVnCrnpsRJJq5nSsiHCE3BYMED2OtsI+cmzIzF1QIfqm5ALf8tEJcO27zV1gKNKRPdhjO0dNWnrzssDQ1tFg==
|
||||
prettier@^1.15.1:
|
||||
version "1.15.1"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.15.1.tgz#06c67106afb1b40e74b002353b2079cc7e0e67bf"
|
||||
integrity sha512-4rgV2hyc/5Pk0XHH4VjJWHRgVjgRbpMfLQjREAhHBtyW1UvTFkjJEsueGYNYYZd9mn97K+1qv0EBwm11zoaSgA==
|
||||
|
||||
pretty-format@^23.6.0:
|
||||
version "23.6.0"
|
||||
|
||||
Reference in New Issue
Block a user