fix NodePath#isGenericType method name

This commit is contained in:
Sebastian McKenzie 2015-06-08 01:00:01 +01:00
parent e5d5a9fb27
commit 3cffe47eea
5 changed files with 7 additions and 7 deletions

View File

@ -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.isTypeAnnotation("Number")) {
if (prop.isGenericType("Number")) {
state.candidates.push(this);
return;
}

View File

@ -16,7 +16,7 @@ function crawl(path) {
if (path.is("_templateLiteralProduced")) {
crawl(path.get("left"));
crawl(path.get("right"));
} else if (!path.isTypeAnnotation("String") && !path.isTypeAnnotation("Number")) {
} else if (!path.isGenericType("String") && !path.isGenericType("Number")) {
path.replaceWith(t.callExpression(t.identifier("String"), [path.node]));
}
}

View File

@ -5,7 +5,7 @@ export var metadata = {
};
export function ForOfStatement(node, parent, scope, file) {
if (this.get("right").isTypeAnnotation("Array")) {
if (this.get("right").isGenericType("Array")) {
return _ForOfStatementArray.call(this, node, scope, file);
}
}

View File

@ -244,10 +244,10 @@ export function _getTypeAnnotation(force?: boolean): ?Object {
var right = this.get("right");
var left = this.get("left");
if (left.isTypeAnnotation("Number") && right.isTypeAnnotation("Number")) {
if (left.isGenericType("Number") && right.isGenericType("Number")) {
// both numbers so this will be a number
return t.numberTypeAnnotation();
} else if (left.isTypeAnnotation("String") || right.isTypeAnnotation("String")) {
} else if (left.isGenericType("String") || right.isGenericType("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 isTypeAnnotation(genericName: string): boolean {
export function isGenericType(genericName: string): boolean {
var type = this.getTypeAnnotation();
if (t.isGenericTypeAnnotation(type) && t.isIdentifier(type.id, { name: genericName })) {

View File

@ -406,7 +406,7 @@ export default class Scope {
if (t.isIdentifier(node)) {
var binding = this.getBinding(node.name);
if (binding && binding.constant && binding.path.isTypeAnnotation("Array")) return node;
if (binding && binding.constant && binding.path.isGenericType("Array")) return node;
}
if (t.isArrayExpression(node)) {