Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support recursive type annotations, fixes #913 #1653

Merged
merged 3 commits into from Jan 27, 2018

Conversation

jetpacmonkey
Copy link
Contributor

Originally written by @phpnode as part of #1138

That PR was closed in favor of #1377, which does not appear to include a solution for the recursive type definition issue.

This allows for code like

type Note = {text: string, children?: Note[]}
type Props = {
  notes: Note[]
};

to run without triggering an infinite loop.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this LGTM overall

@@ -466,11 +466,22 @@ module.exports = {
* @return {Object} The representation of the declaration, empty object means
* the property is declared without the need for further analysis.
*/
function buildTypeAnnotationDeclarationTypes(annotation) {
function buildTypeAnnotationDeclarationTypes(annotation, seen) {
if (seen === void 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typeof seen === 'undefined' please :-) either way, there's no need for void 0 in code that only runs in a node environment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@ljharb ljharb added the bug label Jan 27, 2018
@ljharb ljharb merged commit 843d71a into jsx-eslint:master Jan 27, 2018
This was referenced Feb 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants