diff --git a/lib/babylon-to-espree/toAST.js b/lib/babylon-to-espree/toAST.js index b3da41f0..88349d7c 100644 --- a/lib/babylon-to-espree/toAST.js +++ b/lib/babylon-to-espree/toAST.js @@ -72,6 +72,15 @@ var astTransformVisitor = { delete node.bound; } + if (path.isTypeAlias()) { + node.type = "FunctionDeclaration"; + node.generator = false; + node.async = false; + node.expression = false; + node.params = []; + node.body = node.right; + } + // flow: prevent "no-undef" // for "Component" in: "let x: React.Component" if (path.isQualifiedTypeIdentifier()) { diff --git a/test/non-regression.js b/test/non-regression.js index db5bb59c..7cb61b85 100644 --- a/test/non-regression.js +++ b/test/non-regression.js @@ -1157,6 +1157,18 @@ describe("verify", () => { [] ); }); + + it("cyclic type dependencies #485", () => { + verifyAndAssertMessages( + unpad(` + type Node = { head: T, tail: Node }; + type A = B[]; + type B = number; + `), + { "no-use-before-define": 1 }, + [] + ); + }); }); it("class usage", () => {