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 incorrect typeof parsing in flow #10657
Conversation
@@ -1134,12 +1151,12 @@ export default (superClass: Class<Parser>): Class<Parser> => | |||
): N.FlowQualifiedTypeIdentifier { | |||
startPos = startPos || this.state.start; | |||
startLoc = startLoc || this.state.startLoc; | |||
let node = id || this.parseIdentifier(); | |||
let node = id || this.parseIdentifier(true); |
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 should also replace by flowParseRestrictedIdentifier
here because
interface I extends bool.member {}
will throw unexpected reserved type
, though the error message is not optimal.
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.
Updated with tests!
794d723
to
b685ef8
Compare
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 don't "agree" with some outputs, bug given that this matches Flow ✔️
@@ -22,12 +22,15 @@ import { | |||
SCOPE_OTHER, | |||
} from "../util/scopeflags"; | |||
|
|||
const reservedTypes = [ | |||
const reservedTypes = new Set([ | |||
"_", |
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 wish there was something like https://eslint.org/docs/rules/sort-keys for arrays
@@ -0,0 +1,2 @@ | |||
// @flow | |||
const x: typeof type.interface = "hi"; |
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 would report this as bug to the flow team, given that type.interface
is valid in JS 🤔
@@ -0,0 +1,15 @@ | |||
// @flow | |||
const a: typeof default = "hi"; |
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.
This also seem like a flow bug, since default
is not a valid variable name.
Went and matched parsing behavior in flow parser v0.111.1, and the error message in cases where user wasn't technically overwriting.