-
Notifications
You must be signed in to change notification settings - Fork 488
Fix inferring return type of var function #545
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/** */ | ||
var f = function(x: number): boolean {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
[ | ||
{ | ||
"description": "", | ||
"tags": [], | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 6 | ||
} | ||
}, | ||
"context": { | ||
"loc": { | ||
"start": { | ||
"line": 2, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 39 | ||
} | ||
} | ||
}, | ||
"errors": [], | ||
"name": "f", | ||
"kind": "function", | ||
"params": [ | ||
{ | ||
"title": "param", | ||
"name": "x", | ||
"lineNumber": 2, | ||
"type": { | ||
"type": "NameExpression", | ||
"name": "number" | ||
} | ||
} | ||
], | ||
"returns": [ | ||
{ | ||
"type": { | ||
"type": "NameExpression", | ||
"name": "boolean" | ||
} | ||
} | ||
], | ||
"members": { | ||
"instance": [], | ||
"static": [] | ||
}, | ||
"path": [ | ||
{ | ||
"name": "f", | ||
"kind": "function" | ||
} | ||
], | ||
"namespace": "f" | ||
} | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!-- Generated by documentation.js. Update this documentation by updating the source code. --> | ||
|
||
# f | ||
|
||
**Parameters** | ||
|
||
- `x` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** | ||
|
||
Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
{ | ||
"type": "root", | ||
"children": [ | ||
{ | ||
"type": "html", | ||
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->" | ||
}, | ||
{ | ||
"depth": 1, | ||
"type": "heading", | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"value": "f" | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "strong", | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"value": "Parameters" | ||
} | ||
] | ||
}, | ||
{ | ||
"ordered": false, | ||
"type": "list", | ||
"children": [ | ||
{ | ||
"type": "listItem", | ||
"children": [ | ||
{ | ||
"type": "paragraph", | ||
"children": [ | ||
{ | ||
"type": "inlineCode", | ||
"value": "x" | ||
}, | ||
{ | ||
"type": "text", | ||
"value": " " | ||
}, | ||
{ | ||
"type": "strong", | ||
"children": [ | ||
{ | ||
"href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", | ||
"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", | ||
"type": "link", | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"value": "number" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "text", | ||
"value": " " | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "paragraph", | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"value": "Returns " | ||
}, | ||
{ | ||
"type": "strong", | ||
"children": [ | ||
{ | ||
"href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean", | ||
"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean", | ||
"type": "link", | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"value": "boolean" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "text", | ||
"value": " " | ||
} | ||
] | ||
} | ||
] | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I feel like my change to findTarget might have been bad. However, my other PR makes findTarget return a Path and then it would work to have it return the init again (because paths allows getting the parent).
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.
I'm not sure, but do you want to update the top-level comment:
Infers returns tags by using Flow return type annotations
I'm not sure if this comment still applies int he same way.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.
It still applies. The purpose of this function is to look at the ast node of the comment and infer the return tag based on the Flow return type annotation.