-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Fix some flow issues in @babel/parser flow plugin #8002
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/8112/ |
@@ -2455,6 +2456,7 @@ export default (superClass: Class<Parser>): Class<Parser> => | |||
node.callee = base; | |||
node.typeArguments = this.flowParseTypeParameterInstantiation(); | |||
this.expect(tt.parenL); | |||
// $FlowFixMe |
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.
Not great, but related to the TODO around converting arguments into $ReadOnlyArray
, which requires quite a bit more changes.
packages/babel-parser/src/types.js
Outdated
@@ -541,6 +540,8 @@ export type ConditionalExpression = NodeBase & { | |||
export type CallOrNewBase = NodeBase & { | |||
callee: Expression | Super | Import, | |||
arguments: Array<Expression | SpreadElement>, // TODO: $ReadOnlyArray | |||
optional?: boolean, // For OptionalCallExpression only |
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.
Is moving this something we can avoid if we refactored the code to verify the type before setting the flag? Even if it's a pain, it seems like ideally we'd keep the types as specific as possible.
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.
Agreed on keeping types specific.
I went down a bit of a rabbit hole with trying to refactor for this last night... but actually after a second look, it seems like simply removing the CallExpression typecast makes flow happy.
Thanks so much @existentialism! I went on vacation right after pushing up those PRs, so I really appreciate your cleaning up my mess. I will be sure to keep Flow clean in the future. |
No description provided.