Skip to content

Commit

Permalink
Add tests for keyword class property (prettier#13927)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker authored and medikoo committed Jan 4, 2024
1 parent d55e5df commit 2013a76
Show file tree
Hide file tree
Showing 12 changed files with 607 additions and 2 deletions.
20 changes: 20 additions & 0 deletions src/language-js/parse/postprocess/index.js
Expand Up @@ -153,6 +153,26 @@ function postprocess(ast, options) {
}
break;
}
// TODO: Remove this when https://github.com/meriyah/meriyah/issues/231 get fixed
case "PropertyDefinition":
if (
options.parser === "meriyah" &&
node.static &&
!node.computed &&
!node.key
) {
const name = "static";
const start = locStart(node);
Object.assign(node, {
static: false,
key: {
type: "Identifier",
name,
range: [start, start + name.length],
},
});
}
break;
}
});

Expand Down
2 changes: 0 additions & 2 deletions src/language-js/print/statement.js
Expand Up @@ -174,8 +174,6 @@ const isClassProperty = ({ type }) =>
*/
function shouldPrintSemicolonAfterClassProperty(node, nextNode) {
const name = node.key && node.key.name;
// this isn't actually possible yet with most parsers available today
// so isn't properly tested yet.
if (
(name === "static" || name === "get" || name === "set") &&
!node.value &&
Expand Down

0 comments on commit 2013a76

Please sign in to comment.