rename NodePath#isTypeAnnotationGeneric to isTypeAnnotation
This commit is contained in:
parent
8eee5367f3
commit
9c3cca0d25
@ -33,7 +33,7 @@ var memberExpressionOptimisationVisitor = {
|
||||
// if we know that this member expression is referencing a number then we can safely
|
||||
// optimise it
|
||||
var prop = this.parentPath.get("property");
|
||||
if (prop.isTypeAnnotationGeneric("Number")) {
|
||||
if (prop.isTypeAnnotation("Number")) {
|
||||
state.candidates.push(this);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ function crawl(path) {
|
||||
if (path.is("_templateLiteralProduced")) {
|
||||
crawl(path.get("left"));
|
||||
crawl(path.get("right"));
|
||||
} else if (!path.isTypeAnnotationGeneric("String") && !path.isTypeAnnotationGeneric("Number")) {
|
||||
} else if (!path.isTypeAnnotation("String") && !path.isTypeAnnotation("Number")) {
|
||||
path.replaceWith(t.callExpression(t.identifier("String"), [path.node]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ export var metadata = {
|
||||
};
|
||||
|
||||
export function ForOfStatement(node, parent, scope, file) {
|
||||
if (this.get("right").isTypeAnnotationGeneric("Array")) {
|
||||
if (this.get("right").isTypeAnnotation("Array")) {
|
||||
return _ForOfStatementArray.call(this, node, scope, file);
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ assign(NodePath.prototype, require("./resolution"));
|
||||
assign(NodePath.prototype, require("./replacement"));
|
||||
assign(NodePath.prototype, require("./evaluation"));
|
||||
assign(NodePath.prototype, require("./conversion"));
|
||||
assign(NodePath.prototype, require("./verification"));
|
||||
assign(NodePath.prototype, require("./introspection"));
|
||||
assign(NodePath.prototype, require("./context"));
|
||||
assign(NodePath.prototype, require("./removal"));
|
||||
assign(NodePath.prototype, require("./modification"));
|
||||
|
||||
@ -244,10 +244,10 @@ export function _getTypeAnnotation(force?: boolean): ?Object {
|
||||
var right = this.get("right");
|
||||
var left = this.get("left");
|
||||
|
||||
if (left.isTypeAnnotationGeneric("Number") && right.isTypeAnnotationGeneric("Number")) {
|
||||
if (left.isTypeAnnotation("Number") && right.isTypeAnnotation("Number")) {
|
||||
// both numbers so this will be a number
|
||||
return t.numberTypeAnnotation();
|
||||
} else if (left.isTypeAnnotationGeneric("String") || right.isTypeAnnotationGeneric("String")) {
|
||||
} else if (left.isTypeAnnotation("String") || right.isTypeAnnotation("String")) {
|
||||
// one is a string so the result will be a string
|
||||
return t.stringTypeAnnotation();
|
||||
}
|
||||
@ -333,7 +333,7 @@ export function _getTypeAnnotation(force?: boolean): ?Object {
|
||||
* Description
|
||||
*/
|
||||
|
||||
export function isTypeAnnotationGeneric(genericName: string): boolean {
|
||||
export function isTypeAnnotation(genericName: string): boolean {
|
||||
var type = this.getTypeAnnotation();
|
||||
|
||||
if (t.isGenericTypeAnnotation(type) && t.isIdentifier(type.id, { name: genericName })) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user