-
-
Notifications
You must be signed in to change notification settings - Fork 209
Support cyclic type declarations (#485) #584
Conversation
A type alias shouldn't trigger a no-use-before-define warning just like a function declaration. Cyclic type dependencies are common when using flow. For instance: type Node<T> = { head: T; tail: Node<T> } Fixes babel#485
Sorry for the delay, we need to review your changes before we can merge this. |
node.expression = false; | ||
node.params = []; | ||
node.body = node.right; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have some tests for the babylon-to-espress transform? That is surprising to me that this don't have any side effect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 |
Thanks for this! Is there anything stopping the merge? |
@xtuc hey Sven, any news about this PR? |
Sorry, haven't been able to look at all this in a while! Thanks for the PR. |
Ok weird the test is failing on master |
## The dependency [babel-eslint](https://github.com/babel/babel-eslint) was updated from `9.0.0` to `10.0.0`. This version is **not covered** by your **current version range**. If you don’t accept this pull request, your project will work just like it did before. However, you might be missing out on a bunch of new features, fixes and/or performance improvements from the dependency update. --- <details> <summary>Release Notes for v10.0.0</summary> <h1>v10.0.0</h1> <p>Small breaking change: add a peerDependency starting from the ESLint version that added a parser feature that we were monkeypatching before (and drop that code). If already using ESLint 5 shouldn't be any different.</p> <ul> <li>Bugfix for <code>TypeAlias</code>: <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="290308427" data-permission-text="Issue title is private" data-url="babel/babel-eslint#584" href="https://urls.greenkeeper.io/babel/babel-eslint/pull/584">#584</a></li> </ul> <div class="highlight highlight-source-js"><pre><span class="pl-c"><span class="pl-c">/*</span> @flow <span class="pl-c">*/</span></span> type <span class="pl-c1">Node</span><span class="pl-k"><</span><span class="pl-c1">T</span><span class="pl-k">></span> <span class="pl-k">=</span> { head<span class="pl-k">:</span> <span class="pl-c1">T</span>; tail<span class="pl-k">:</span> <span class="pl-c1">Node</span><span class="pl-k"><</span><span class="pl-c1">T</span><span class="pl-k">></span> } <span class="pl-c"><span class="pl-c">//</span> or </span> type <span class="pl-c1">File</span> <span class="pl-k">=</span> {chunks<span class="pl-k">:</span> <span class="pl-c1">Array</span><span class="pl-k"><</span>Chunk<span class="pl-k">></span>} type Chunk <span class="pl-k">=</span> {file<span class="pl-k">:</span> <span class="pl-c1">File</span>}</pre></div> <ul> <li>Update to test against ESLint 5, add a peerDependency: <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="363695123" data-permission-text="Issue title is private" data-url="babel/babel-eslint#689" href="https://urls.greenkeeper.io/babel/babel-eslint/pull/689">#689</a></li> <li>Drop monkeypatching behavior: <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="363706472" data-permission-text="Issue title is private" data-url="babel/babel-eslint#690" href="https://urls.greenkeeper.io/babel/babel-eslint/pull/690">#690</a></li> </ul> </details> <details> <summary>Commits</summary> <p>The new version differs by 5 commits.</p> <ul> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/8f78e280a22def1128cd847b73fd7f221a047ed2"><code>8f78e28</code></a> <code>10.0.0</code></li> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/717fba7f5605f4dc1cc5531a7c24d5c9ab37a8a2"><code>717fba7</code></a> <code>test value should be switched</code></li> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/020d012c554913fea137f4129798ce31a4896dfe"><code>020d012</code></a> <code>Treat type alias declarationlike function declaration (#584)</code></li> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/b400cb1b38aaa8999d2a43f381f3ee861469ab98"><code>b400cb1</code></a> <code>Test eslint5, update peerDep (#690)</code></li> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/c333bd64cb014cac8b56062421e9a5c0d28d798b"><code>c333bd6</code></a> <code>Drop old monkeypatching behavior (#689)</code></li> </ul> <p>See the <a href="https://urls.greenkeeper.io/babel/babel-eslint/compare/6aa8b6f02ff83cfb14eae2432f226f113929a50f...8f78e280a22def1128cd847b73fd7f221a047ed2">full diff</a></p> </details> <details> <summary>FAQ and help</summary> There is a collection of [frequently asked questions](https://greenkeeper.io/faq.html). If those don’t help, you can always [ask the humans behind Greenkeeper](https://github.com/greenkeeperio/greenkeeper/issues/new). </details> --- Your [Greenkeeper](https://greenkeeper.io) bot 🌴
## The devDependency [babel-eslint](https://github.com/babel/babel-eslint) was updated from `9.0.0` to `10.0.0`. This version is **not covered** by your **current version range**. If you don’t accept this pull request, your project will work just like it did before. However, you might be missing out on a bunch of new features, fixes and/or performance improvements from the dependency update. --- <details> <summary>Release Notes for v10.0.0</summary> <h1>v10.0.0</h1> <p>Small breaking change: add a peerDependency starting from the ESLint version that added a parser feature that we were monkeypatching before (and drop that code). If already using ESLint 5 shouldn't be any different.</p> <ul> <li>Bugfix for <code>TypeAlias</code>: <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="290308427" data-permission-text="Issue title is private" data-url="babel/babel-eslint#584" href="https://urls.greenkeeper.io/babel/babel-eslint/pull/584">#584</a></li> </ul> <div class="highlight highlight-source-js"><pre><span class="pl-c"><span class="pl-c">/*</span> @flow <span class="pl-c">*/</span></span> type <span class="pl-c1">Node</span><span class="pl-k"><</span><span class="pl-c1">T</span><span class="pl-k">></span> <span class="pl-k">=</span> { head<span class="pl-k">:</span> <span class="pl-c1">T</span>; tail<span class="pl-k">:</span> <span class="pl-c1">Node</span><span class="pl-k"><</span><span class="pl-c1">T</span><span class="pl-k">></span> } <span class="pl-c"><span class="pl-c">//</span> or </span> type <span class="pl-c1">File</span> <span class="pl-k">=</span> {chunks<span class="pl-k">:</span> <span class="pl-c1">Array</span><span class="pl-k"><</span>Chunk<span class="pl-k">></span>} type Chunk <span class="pl-k">=</span> {file<span class="pl-k">:</span> <span class="pl-c1">File</span>}</pre></div> <ul> <li>Update to test against ESLint 5, add a peerDependency: <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="363695123" data-permission-text="Issue title is private" data-url="babel/babel-eslint#689" href="https://urls.greenkeeper.io/babel/babel-eslint/pull/689">#689</a></li> <li>Drop monkeypatching behavior: <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="363706472" data-permission-text="Issue title is private" data-url="babel/babel-eslint#690" href="https://urls.greenkeeper.io/babel/babel-eslint/pull/690">#690</a></li> </ul> </details> <details> <summary>Commits</summary> <p>The new version differs by 5 commits.</p> <ul> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/8f78e280a22def1128cd847b73fd7f221a047ed2"><code>8f78e28</code></a> <code>10.0.0</code></li> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/717fba7f5605f4dc1cc5531a7c24d5c9ab37a8a2"><code>717fba7</code></a> <code>test value should be switched</code></li> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/020d012c554913fea137f4129798ce31a4896dfe"><code>020d012</code></a> <code>Treat type alias declarationlike function declaration (#584)</code></li> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/b400cb1b38aaa8999d2a43f381f3ee861469ab98"><code>b400cb1</code></a> <code>Test eslint5, update peerDep (#690)</code></li> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/c333bd64cb014cac8b56062421e9a5c0d28d798b"><code>c333bd6</code></a> <code>Drop old monkeypatching behavior (#689)</code></li> </ul> <p>See the <a href="https://urls.greenkeeper.io/babel/babel-eslint/compare/6aa8b6f02ff83cfb14eae2432f226f113929a50f...8f78e280a22def1128cd847b73fd7f221a047ed2">full diff</a></p> </details> <details> <summary>FAQ and help</summary> There is a collection of [frequently asked questions](https://greenkeeper.io/faq.html). If those don’t help, you can always [ask the humans behind Greenkeeper](https://github.com/greenkeeperio/greenkeeper/issues/new). </details> --- Your [Greenkeeper](https://greenkeeper.io) bot 🌴
## The devDependency [babel-eslint](https://github.com/babel/babel-eslint) was updated from `9.0.0` to `10.0.0`. This version is **not covered** by your **current version range**. If you don’t accept this pull request, your project will work just like it did before. However, you might be missing out on a bunch of new features, fixes and/or performance improvements from the dependency update. --- <details> <summary>Release Notes for v10.0.0</summary> <h1>v10.0.0</h1> <p>Small breaking change: add a peerDependency starting from the ESLint version that added a parser feature that we were monkeypatching before (and drop that code). If already using ESLint 5 shouldn't be any different.</p> <ul> <li>Bugfix for <code>TypeAlias</code>: <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="290308427" data-permission-text="Issue title is private" data-url="babel/babel-eslint#584" href="https://urls.greenkeeper.io/babel/babel-eslint/pull/584">#584</a></li> </ul> <div class="highlight highlight-source-js"><pre><span class="pl-c"><span class="pl-c">/*</span> @flow <span class="pl-c">*/</span></span> type <span class="pl-c1">Node</span><span class="pl-k"><</span><span class="pl-c1">T</span><span class="pl-k">></span> <span class="pl-k">=</span> { head<span class="pl-k">:</span> <span class="pl-c1">T</span>; tail<span class="pl-k">:</span> <span class="pl-c1">Node</span><span class="pl-k"><</span><span class="pl-c1">T</span><span class="pl-k">></span> } <span class="pl-c"><span class="pl-c">//</span> or </span> type <span class="pl-c1">File</span> <span class="pl-k">=</span> {chunks<span class="pl-k">:</span> <span class="pl-c1">Array</span><span class="pl-k"><</span>Chunk<span class="pl-k">></span>} type Chunk <span class="pl-k">=</span> {file<span class="pl-k">:</span> <span class="pl-c1">File</span>}</pre></div> <ul> <li>Update to test against ESLint 5, add a peerDependency: <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="363695123" data-permission-text="Issue title is private" data-url="babel/babel-eslint#689" href="https://urls.greenkeeper.io/babel/babel-eslint/pull/689">#689</a></li> <li>Drop monkeypatching behavior: <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="363706472" data-permission-text="Issue title is private" data-url="babel/babel-eslint#690" href="https://urls.greenkeeper.io/babel/babel-eslint/pull/690">#690</a></li> </ul> </details> <details> <summary>Commits</summary> <p>The new version differs by 5 commits.</p> <ul> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/8f78e280a22def1128cd847b73fd7f221a047ed2"><code>8f78e28</code></a> <code>10.0.0</code></li> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/717fba7f5605f4dc1cc5531a7c24d5c9ab37a8a2"><code>717fba7</code></a> <code>test value should be switched</code></li> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/020d012c554913fea137f4129798ce31a4896dfe"><code>020d012</code></a> <code>Treat type alias declarationlike function declaration (#584)</code></li> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/b400cb1b38aaa8999d2a43f381f3ee861469ab98"><code>b400cb1</code></a> <code>Test eslint5, update peerDep (#690)</code></li> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/c333bd64cb014cac8b56062421e9a5c0d28d798b"><code>c333bd6</code></a> <code>Drop old monkeypatching behavior (#689)</code></li> </ul> <p>See the <a href="https://urls.greenkeeper.io/babel/babel-eslint/compare/6aa8b6f02ff83cfb14eae2432f226f113929a50f...8f78e280a22def1128cd847b73fd7f221a047ed2">full diff</a></p> </details> <details> <summary>FAQ and help</summary> There is a collection of [frequently asked questions](https://greenkeeper.io/faq.html). If those don’t help, you can always [ask the humans behind Greenkeeper](https://github.com/greenkeeperio/greenkeeper/issues/new). </details> --- Your [Greenkeeper](https://greenkeeper.io) bot 🌴
## The devDependency [babel-eslint](https://github.com/babel/babel-eslint) was updated from `9.0.0` to `10.0.0`. This version is **not covered** by your **current version range**. If you don’t accept this pull request, your project will work just like it did before. However, you might be missing out on a bunch of new features, fixes and/or performance improvements from the dependency update. --- <details> <summary>Release Notes for v10.0.0</summary> <h1>v10.0.0</h1> <p>Small breaking change: add a peerDependency starting from the ESLint version that added a parser feature that we were monkeypatching before (and drop that code). If already using ESLint 5 shouldn't be any different.</p> <ul> <li>Bugfix for <code>TypeAlias</code>: <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="290308427" data-permission-text="Issue title is private" data-url="babel/babel-eslint#584" href="https://urls.greenkeeper.io/babel/babel-eslint/pull/584">#584</a></li> </ul> <div class="highlight highlight-source-js"><pre><span class="pl-c"><span class="pl-c">/*</span> @flow <span class="pl-c">*/</span></span> type <span class="pl-c1">Node</span><span class="pl-k"><</span><span class="pl-c1">T</span><span class="pl-k">></span> <span class="pl-k">=</span> { head<span class="pl-k">:</span> <span class="pl-c1">T</span>; tail<span class="pl-k">:</span> <span class="pl-c1">Node</span><span class="pl-k"><</span><span class="pl-c1">T</span><span class="pl-k">></span> } <span class="pl-c"><span class="pl-c">//</span> or </span> type <span class="pl-c1">File</span> <span class="pl-k">=</span> {chunks<span class="pl-k">:</span> <span class="pl-c1">Array</span><span class="pl-k"><</span>Chunk<span class="pl-k">></span>} type Chunk <span class="pl-k">=</span> {file<span class="pl-k">:</span> <span class="pl-c1">File</span>}</pre></div> <ul> <li>Update to test against ESLint 5, add a peerDependency: <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="363695123" data-permission-text="Issue title is private" data-url="babel/babel-eslint#689" href="https://urls.greenkeeper.io/babel/babel-eslint/pull/689">#689</a></li> <li>Drop monkeypatching behavior: <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="363706472" data-permission-text="Issue title is private" data-url="babel/babel-eslint#690" href="https://urls.greenkeeper.io/babel/babel-eslint/pull/690">#690</a></li> </ul> </details> <details> <summary>Commits</summary> <p>The new version differs by 5 commits.</p> <ul> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/8f78e280a22def1128cd847b73fd7f221a047ed2"><code>8f78e28</code></a> <code>10.0.0</code></li> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/717fba7f5605f4dc1cc5531a7c24d5c9ab37a8a2"><code>717fba7</code></a> <code>test value should be switched</code></li> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/020d012c554913fea137f4129798ce31a4896dfe"><code>020d012</code></a> <code>Treat type alias declarationlike function declaration (#584)</code></li> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/b400cb1b38aaa8999d2a43f381f3ee861469ab98"><code>b400cb1</code></a> <code>Test eslint5, update peerDep (#690)</code></li> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/c333bd64cb014cac8b56062421e9a5c0d28d798b"><code>c333bd6</code></a> <code>Drop old monkeypatching behavior (#689)</code></li> </ul> <p>See the <a href="https://urls.greenkeeper.io/babel/babel-eslint/compare/6aa8b6f02ff83cfb14eae2432f226f113929a50f...8f78e280a22def1128cd847b73fd7f221a047ed2">full diff</a></p> </details> <details> <summary>FAQ and help</summary> There is a collection of [frequently asked questions](https://greenkeeper.io/faq.html). If those don’t help, you can always [ask the humans behind Greenkeeper](https://github.com/greenkeeperio/greenkeeper/issues/new). </details> --- Your [Greenkeeper](https://greenkeeper.io) bot 🌴
## The devDependency [babel-eslint](https://github.com/babel/babel-eslint) was updated from `9.0.0` to `10.0.0`. This version is **not covered** by your **current version range**. If you don’t accept this pull request, your project will work just like it did before. However, you might be missing out on a bunch of new features, fixes and/or performance improvements from the dependency update. --- <details> <summary>Release Notes for v10.0.0</summary> <h1>v10.0.0</h1> <p>Small breaking change: add a peerDependency starting from the ESLint version that added a parser feature that we were monkeypatching before (and drop that code). If already using ESLint 5 shouldn't be any different.</p> <ul> <li>Bugfix for <code>TypeAlias</code>: <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="290308427" data-permission-text="Issue title is private" data-url="babel/babel-eslint#584" href="https://urls.greenkeeper.io/babel/babel-eslint/pull/584">#584</a></li> </ul> <div class="highlight highlight-source-js"><pre><span class="pl-c"><span class="pl-c">/*</span> @flow <span class="pl-c">*/</span></span> type <span class="pl-c1">Node</span><span class="pl-k"><</span><span class="pl-c1">T</span><span class="pl-k">></span> <span class="pl-k">=</span> { head<span class="pl-k">:</span> <span class="pl-c1">T</span>; tail<span class="pl-k">:</span> <span class="pl-c1">Node</span><span class="pl-k"><</span><span class="pl-c1">T</span><span class="pl-k">></span> } <span class="pl-c"><span class="pl-c">//</span> or </span> type <span class="pl-c1">File</span> <span class="pl-k">=</span> {chunks<span class="pl-k">:</span> <span class="pl-c1">Array</span><span class="pl-k"><</span>Chunk<span class="pl-k">></span>} type Chunk <span class="pl-k">=</span> {file<span class="pl-k">:</span> <span class="pl-c1">File</span>}</pre></div> <ul> <li>Update to test against ESLint 5, add a peerDependency: <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="363695123" data-permission-text="Issue title is private" data-url="babel/babel-eslint#689" href="https://urls.greenkeeper.io/babel/babel-eslint/pull/689">#689</a></li> <li>Drop monkeypatching behavior: <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="363706472" data-permission-text="Issue title is private" data-url="babel/babel-eslint#690" href="https://urls.greenkeeper.io/babel/babel-eslint/pull/690">#690</a></li> </ul> </details> <details> <summary>Commits</summary> <p>The new version differs by 5 commits.</p> <ul> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/8f78e280a22def1128cd847b73fd7f221a047ed2"><code>8f78e28</code></a> <code>10.0.0</code></li> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/717fba7f5605f4dc1cc5531a7c24d5c9ab37a8a2"><code>717fba7</code></a> <code>test value should be switched</code></li> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/020d012c554913fea137f4129798ce31a4896dfe"><code>020d012</code></a> <code>Treat type alias declarationlike function declaration (#584)</code></li> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/b400cb1b38aaa8999d2a43f381f3ee861469ab98"><code>b400cb1</code></a> <code>Test eslint5, update peerDep (#690)</code></li> <li><a href="https://urls.greenkeeper.io/babel/babel-eslint/commit/c333bd64cb014cac8b56062421e9a5c0d28d798b"><code>c333bd6</code></a> <code>Drop old monkeypatching behavior (#689)</code></li> </ul> <p>See the <a href="https://urls.greenkeeper.io/babel/babel-eslint/compare/6aa8b6f02ff83cfb14eae2432f226f113929a50f...8f78e280a22def1128cd847b73fd7f221a047ed2">full diff</a></p> </details> <details> <summary>FAQ and help</summary> There is a collection of [frequently asked questions](https://greenkeeper.io/faq.html). If those don’t help, you can always [ask the humans behind Greenkeeper](https://github.com/greenkeeperio/greenkeeper/issues/new). </details> --- Your [Greenkeeper](https://greenkeeper.io) bot 🌴
This change (generally) breaks eslint plugins that use |
Yeah I think we will need to revert, was trying to look into the solution earlier |
Using a type before its definition shouldn't trigger a no-use-before-define warning. Flow types should experience them same behavior as function declarations (they behave currently more like function expressions).
Cyclic type dependencies are common when using flow.
For instance:
Fixes #485