From 01b243347f07dae8e78a220775d57061a65b82ba Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Thu, 25 Jun 2015 22:55:46 +0100 Subject: [PATCH] add NodePath#baseTypeStrictlyMatches method --- src/babel/traversal/path/inference/index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/babel/traversal/path/inference/index.js b/src/babel/traversal/path/inference/index.js index ef1fc1aa88..2fa3b3c66f 100644 --- a/src/babel/traversal/path/inference/index.js +++ b/src/babel/traversal/path/inference/index.js @@ -76,6 +76,8 @@ function _isBaseType(baseName: string, type?, soft?): boolean { return t.isAnyTypeAnnotation(type); } else if (baseName === "mixed") { return t.isMixedTypeAnnotation(type); + } else if (baseName === "void") { + return t.isVoidTypeAnnotation(type); } else { if (soft) { return false; @@ -105,6 +107,19 @@ export function couldBeBaseType(name: string): boolean { } } +/** + * Description + */ + +export function baseTypeStrictlyMatches(right: NodePath) { + var left = this.getTypeAnnotation(); + right = right.getTypeAnnotation(); + + if (!t.isAnyTypeAnnotation() && t.isFlowBaseAnnotation(left)) { + return right.type === left.type; + } +} + /** * Description */