From 8c3aab9a26d4ec68dc4945cd7f136c0566679802 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Sat, 6 Jun 2015 03:33:32 +0100 Subject: [PATCH] add support for async functions to type inferrence --- src/babel/traversal/path/resolution.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/babel/traversal/path/resolution.js b/src/babel/traversal/path/resolution.js index 70f8dfd4dc..c95c6a6887 100644 --- a/src/babel/traversal/path/resolution.js +++ b/src/babel/traversal/path/resolution.js @@ -272,7 +272,17 @@ export function _inferTypeAnnotation(force?: boolean): ?Object { if (callPath) { var callee = callPath.resolve(); // todo: read typescript/flow interfaces - if (callee.isNodeType("Function")) return callee.node.returnType; + if (callee.isNodeType("Function")) { + if (callee.is("async")) { + if (callee.is("generator")) { + // todo + } else { + return t.genericTypeAnnotation(t.identifier("Promise")); + } + } else { + return callee.node.returnType; + } + } } }