Skip to content

Commit e4240ae

Browse files
authored
Add tests for keyword class property (#13927)
1 parent 655a161 commit e4240ae

12 files changed

Lines changed: 607 additions & 2 deletions

File tree

src/language-js/parse/postprocess/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,26 @@ function postprocess(ast, options) {
153153
}
154154
break;
155155
}
156+
// TODO: Remove this when https://github.com/meriyah/meriyah/issues/231 get fixed
157+
case "PropertyDefinition":
158+
if (
159+
options.parser === "meriyah" &&
160+
node.static &&
161+
!node.computed &&
162+
!node.key
163+
) {
164+
const name = "static";
165+
const start = locStart(node);
166+
Object.assign(node, {
167+
static: false,
168+
key: {
169+
type: "Identifier",
170+
name,
171+
range: [start, start + name.length],
172+
},
173+
});
174+
}
175+
break;
156176
}
157177
});
158178

src/language-js/print/statement.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@ const isClassProperty = ({ type }) =>
174174
*/
175175
function shouldPrintSemicolonAfterClassProperty(node, nextNode) {
176176
const name = node.key && node.key.name;
177-
// this isn't actually possible yet with most parsers available today
178-
// so isn't properly tested yet.
179177
if (
180178
(name === "static" || name === "get" || name === "set") &&
181179
!node.value &&

0 commit comments

Comments
 (0)