Skip to content
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

Support decorator auto accessors syntax #13919

Merged
merged 12 commits into from Dec 5, 2022
5 changes: 4 additions & 1 deletion src/language-js/print/statement.js
Expand Up @@ -177,7 +177,10 @@ const isClassProperty = ({ type }) =>
function shouldPrintSemicolonAfterClassProperty(node, nextNode) {
const name = node.key && node.key.name;
Copy link
Sponsor Member

@fisker fisker Dec 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are here. Let's remove this chaining, I don't think the key can be nullish here.

Suggested change
const name = node.key && node.key.name;
const { name } = node.key;

if (
(name === "static" || name === "get" || name === "set") &&
(name === "static" ||
fisker marked this conversation as resolved.
Show resolved Hide resolved
name === "get" ||
name === "set" ||
name === "accessor") &&
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a TODO comment about microsoft/TypeScript#51707

!node.value &&
!node.typeAnnotation
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

printClassProperty also prints ? or ! here

printOptionalToken(path),
, not sure if we can omit semi here if those tokens exists, but we can investigate in feature.

We should also test private fields, since we use .key.name directly without check type.

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not checking computed either...

) {
Expand Down