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
[flow] Add support for parsing _
as implicit instantiation in call/new
#8883
[flow] Add support for parsing _
as implicit instantiation in call/new
#8883
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/9327/ |
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.
Just one little thing, otherwise looks good.
checkReservedType(word: string, startLoc: number) { | ||
this.checkNotUnderscore(word); |
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.
Can we remove this, I covered this case in #8965 by adding _ to the primitiveTypes
array.
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.
Yeah, adding to primitiveTypes sounds like a much better way to go.
…all-implicit-instantiation
…-implicit-instantiation
Thanks. The remaining travis failure has nothing to do with this PR. |
Thanks for the help! |
Fixes #1, Fixes #2
In facebook/flow@fb23b93, flow started to treat "_" used as type arguments to calls/new (
test<_>()
ornew test<_>()
) to mean to implicitly instantiate a type variable for that type parameter.In that change, Flow disallowed the use of
_
as a type identifier and it can only be used as a type argument in call/new. The estree AST flow outputs still prints_
in call/new type arguments as aGenericTypeAnnotation
with Identifier_
, which this change mimics.No old tests had to be re-recorded, since the output AST did not change. Any programs using "_" as a type identifier name will now have a parse error when using the flow parser after this change. As an example, every use of "_" in the following code would cause a parse error in flow:
This feature will be released in flow v0.84.0