more estree updates - finish flow parsing
This commit is contained in:
@@ -13,6 +13,7 @@ export default function (opts, code, callback) {
|
||||
allowReturnOutsideFunction: opts.looseModules,
|
||||
ecmaVersion: 6,
|
||||
strictMode: opts.strictMode,
|
||||
sourceType: opts.sourceType,
|
||||
onComment: comments,
|
||||
locations: true,
|
||||
features: opts.features || {},
|
||||
@@ -21,8 +22,8 @@ export default function (opts, code, callback) {
|
||||
ranges: true
|
||||
};
|
||||
|
||||
parseOpts.plugins.flow = true;
|
||||
parseOpts.plugins.jsx = true;
|
||||
parseOpts.plugins.flow = true;
|
||||
|
||||
var ast = acorn.parse(code, parseOpts);
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"blacklist": ["useStrict", "es6.blockScoping", "regenerator"],
|
||||
"loose": ["es6.modules"],
|
||||
"breakConfig": true
|
||||
"loose": ["es6.modules"]
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ class ClassTransformer {
|
||||
for (var i = 0; i < classBody.length; i++) {
|
||||
var node = classBody[i];
|
||||
if (t.isMethodDefinition(node)) {
|
||||
var isConstructor = (!node.computed && t.isIdentifier(node.key, { name: "constructor" })) || t.isLiteral(node.key, { value: "constructor" });
|
||||
var isConstructor = node.kind === "constructor";
|
||||
if (isConstructor) this.verifyConstructor(classBodyPaths[i]);
|
||||
|
||||
var replaceSupers = new ReplaceSupers({
|
||||
@@ -332,10 +332,6 @@ class ClassTransformer {
|
||||
*/
|
||||
|
||||
pushConstructor(method: { type: "MethodDefinition" }) {
|
||||
if (method.kind) {
|
||||
throw this.file.errorWithNode(method, messages.get("classesIllegalConstructorKind"));
|
||||
}
|
||||
|
||||
var construct = this.constructor;
|
||||
var fn = method.value;
|
||||
|
||||
|
||||
@@ -37,23 +37,15 @@ traverse.node = function (node, opts, scope, state, parentPath) {
|
||||
}
|
||||
};
|
||||
|
||||
const CLEAR_KEYS = [
|
||||
"trailingComments", "leadingComments", "_declarations", "extendedRange",
|
||||
"_paths", "tokens", "range", "start", "end", "loc", "raw"
|
||||
];
|
||||
|
||||
function clearNode(node) {
|
||||
node._declarations = null;
|
||||
node.extendedRange = null;
|
||||
node._paths = null;
|
||||
node.tokens = null;
|
||||
node.range = null;
|
||||
node.start = null;
|
||||
node.end = null;
|
||||
node.loc = null;
|
||||
node.raw = null;
|
||||
|
||||
if (Array.isArray(node.trailingComments)) {
|
||||
clearComments(node.trailingComments);
|
||||
}
|
||||
|
||||
if (Array.isArray(node.leadingComments)) {
|
||||
clearComments(node.leadingComments);
|
||||
for (var i = 0; i < CLEAR_KEYS.length; i++) {
|
||||
var key = CLEAR_KEYS[i];
|
||||
if (node[key] != null) node[key] = null;
|
||||
}
|
||||
|
||||
for (var key in node) {
|
||||
|
||||
Reference in New Issue
Block a user