-
Notifications
You must be signed in to change notification settings - Fork 71
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
Consistent returns for read_variable_declaration
#1141
base: main
Are you sure you want to change the base?
Conversation
} else { | ||
this.expect([",", ";", "="]); | ||
return result(propName, null, nullable, type, attrs || []); |
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.
here, readonly is not passed.
"kind": "property", | ||
"name": Identifier { | ||
"kind": "identifier", | ||
"name": "onst", | ||
}, | ||
"nullable": Name { |
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.
The snapshot show that what was set was incorrect: instead of a boolean value we had some objects.
src/parser/class.js
Outdated
type, | ||
attrs || [], | ||
); | ||
value = this.next().read_expr(); | ||
} else { | ||
this.expect([",", ";", "="]); |
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 think we need to drop the "="
in th eexpect, we already handled that with the previous if condition.
this.expect([",", ";", "="]); | |
this.expect([",", ";"]); |
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.
"," and ";" are handled by the first if.
I think this line is here to show an error message indicating that we expect one of those 3 things.
I figured this out while working on adding support for property hooks.
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.
Looks good, if we could just streamline the if else when looking for a default value, they we can merge this.
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.
LGTM
I do not have permission to merge 😄 . |
While working on adding support for property hooks, I realized that the function parsing class property does not always call the "return" function with the same parameters: in some instance, the parameter
readonly
is not being passed done.This PR fix that by having 1 call to return despite multiple branches in the logic.