From 0ebdf8bedfdfc056b70244fa0e9699afe12f52d0 Mon Sep 17 00:00:00 2001 From: Henry Zhu Date: Tue, 2 Jun 2015 08:59:38 -0400 Subject: [PATCH] add flow exceptions for polymorphic types and mixed - Ref #109 --- index.js | 4 ++++ test/non-regression.js | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/index.js b/index.js index 0977fd42..5055788f 100644 --- a/index.js +++ b/index.js @@ -163,6 +163,10 @@ function monkeypatch() { if (node.typeAnnotation) { visitTypeAnnotation.call(this, node.typeAnnotation); } else if (node.type === "Identifier") { + // exception for polymorphic types: , , etc + if (node.name.length === 1 && node.name === node.name.toUpperCase()) { + return; + } this.visit(node); } else { visitTypeAnnotation.call(this, node); diff --git a/test/non-regression.js b/test/non-regression.js index 9b0b783d..b5c6995e 100644 --- a/test/non-regression.js +++ b/test/non-regression.js @@ -297,6 +297,26 @@ describe("verify", function () { ); }); + it("polymorphpic types #109", function () { + verifyAndAssertMessages([ + "export default function groupByEveryN(array: Array, n: number): Array> {}" + ].join("\n"), + { "no-unused-vars": 1, "no-undef": 1 }, + [] + ); + }); + + it("types definition from import", function () { + verifyAndAssertMessages([ + "import type Promise from 'bluebird';", + "type Operation = () => Promise;", + "x: Operation;" + ].join("\n"), + { "no-unused-vars": 1, "no-undef": 1 }, + [] + ); + }); + it("1", function () { verifyAndAssertMessages( [