Removed `@flow` annotation from files that don't actually pass Flow check at the moment. These will be added back file by file once the files are properly converted to use Flow. Closes #3064
39 lines
847 B
JavaScript
39 lines
847 B
JavaScript
// This file contains methods that convert the path node into another node or some other type of data.
|
|
|
|
import * as t from "babel-types";
|
|
|
|
export function toComputedKey(): Object {
|
|
let node = this.node;
|
|
|
|
let key;
|
|
if (this.isMemberExpression()) {
|
|
key = node.property;
|
|
} else if (this.isProperty() || this.isMethod()) {
|
|
key = node.key;
|
|
} else {
|
|
throw new ReferenceError("todo");
|
|
}
|
|
|
|
if (!node.computed) {
|
|
if (t.isIdentifier(key)) key = t.stringLiteral(key.name);
|
|
}
|
|
|
|
return key;
|
|
}
|
|
|
|
export function ensureBlock() {
|
|
return t.ensureBlock(this.node);
|
|
}
|
|
|
|
export function arrowFunctionToShadowed() {
|
|
// todo: maybe error
|
|
if (!this.isArrowFunctionExpression()) return;
|
|
|
|
this.ensureBlock();
|
|
|
|
let { node } = this;
|
|
node.expression = false;
|
|
node.type = "FunctionExpression";
|
|
node.shadow = node.shadow || true;
|
|
}
|