-
-
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
[breaking] Remove TSParenthesizedType
unless createParenthesizedExpressions is enabled
#9546
Comments
I want to try to deal with it |
@nicolo-ribaudo Input: It makes a different sense Input: Parsing error |
Seems like we should create |
The second one is like a Parentheses are handled by For example, to fix your first case we would need a function like this: export function TSInferType(node: Object, parent: Object): boolean {
return (
t.isTSArrayType(parent) ||
t.isTSOptionalType(parent)
);
} This is already a bug in Babel 7, because a plugin could create a On the other hand, I cannot reproduce the first case. Maybe the AST generated by the parser is wrong? You need to manually check if it is correct, and if it isn't it's probably caused by some changes in the parser logic while disabling the I'd be happy to look at a "work in progress" PR if you need help. |
@nicolo-ribaudo #11200 look at the failed tests |
I think that I will fix babel 7 in a separated PR |
Thanks! We will do like this:
|
It there an issue with a broken example for babel 7? |
Now I can't reproduce the second case... |
I will write a reproduction for Babel 7 in ~1 hour |
Sorry for this super long hour! 😛 You can add this test to it("wraps around infer inside an array type", () => {
const type = t.tsArrayType(
t.tsInferType(t.tsTypeParameter(null, null, "T")),
);
const output = generate(type).code;
expect(output).toBe("(infer T)[]");
}); |
I don't understand why we generate
TSParenthesizedType
nodes by default. Example: AST Explorer. It isn't needed (it isn't part of the AST, but more a CST thing) and we don't use it from Flow.Also, we should add it to Flow when that option is enabled.
Ref: #8025
The text was updated successfully, but these errors were encountered: