GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Avoid extra parens in TS `as`/`satisfies` by nicolo-ribaudo · Pull Request #16617 · babel/babel Conversation
Member
We were being extra conservative and always printing parens in our code generator. This PR avoids it, by considering
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
nicolo-ribaudo
commented
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here parens are not actually necessary, but our AST has a TSParenthesizedType node so they are preserved. Babel 8 removes the parens, because TSParenthesizedType is not enabled by default anymore.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
nicolo-ribaudo
force-pushed
the
ts-unnecessary-parens
branch
from
c8c3390 to
ceff568
Compare
|
There was an error while loading. Please reload this page.
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/57279 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This is awesome!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| function getBinaryPrecedence(node: t.Node) { | ||
| if (node.type === "BinaryExpression" || node.type === "LogicalExpression") { | ||
| return PRECEDENCE.get(node.operator); | ||
| } | ||
| if (node.type === "TSAsExpression" || node.type === "TSSatisfiesExpression") { | ||
| return PRECEDENCE.get("in"); | ||
| } | ||
| } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can we add a parameter nodeType to use the parentType of the caller?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
6ac192d to
f083dbe
Compare
|
I noticed this PR was tagged |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
by mistake :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
The latest Babel version is causing breakage in Athena Crisis, and I believe this PR is related. Specifically it's breaking the common patterns below: Spread is somehow broken due to the
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Thanks for the report — that's an easy fix, I'll try to have it ready today. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.