From 20803ded6c60ee571a2b3deba1f9d9df177916a8 Mon Sep 17 00:00:00 2001 From: Zack Date: Mon, 12 Dec 2022 10:59:40 -0500 Subject: [PATCH 1/3] Update astring.js --- src/astring.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/astring.js b/src/astring.js index 9f54e1ea..57292c82 100644 --- a/src/astring.js +++ b/src/astring.js @@ -825,7 +825,13 @@ export const GENERATOR = { if (node.static) { state.write('static ') } + if (node.computed) { + node.write('['); + } this[node.key.type](node.key, state) + if (node.computed) { + node.write(']'); + } if (node.value == null) { return } From 52fe0b6e8e19a14cd7d7bc999c300d13e18216e7 Mon Sep 17 00:00:00 2001 From: Zack Date: Mon, 12 Dec 2022 11:01:41 -0500 Subject: [PATCH 2/3] Update class.js --- src/tests/fixtures/syntax/class.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tests/fixtures/syntax/class.js b/src/tests/fixtures/syntax/class.js index 344c517c..d5f25e2f 100644 --- a/src/tests/fixtures/syntax/class.js +++ b/src/tests/fixtures/syntax/class.js @@ -47,6 +47,8 @@ function* a() { async function b() { class A extends (await a()) {} } + +const e = 'test'; class O { #a = 42 #b() {} @@ -55,4 +57,5 @@ class O { static { const a = 3; } + static [e] = 123; } From 33383643a328edd365e82edfebffb187fe4c053d Mon Sep 17 00:00:00 2001 From: David Bonnet Date: Wed, 21 Dec 2022 01:54:52 +0000 Subject: [PATCH 3/3] Fix static property generator --- src/astring.js | 8 ++++++-- src/tests/fixtures/syntax/class.js | 7 +++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/astring.js b/src/astring.js index 57292c82..d19c34f0 100644 --- a/src/astring.js +++ b/src/astring.js @@ -826,17 +826,21 @@ export const GENERATOR = { state.write('static ') } if (node.computed) { - node.write('['); + state.write('[') } this[node.key.type](node.key, state) if (node.computed) { - node.write(']'); + state.write(']') } if (node.value == null) { + if (node.key.type[0] !== 'F') { + state.write(';') + } return } state.write(' = ') this[node.value.type](node.value, state) + state.write(';') }, ObjectPattern(node, state) { state.write('{') diff --git a/src/tests/fixtures/syntax/class.js b/src/tests/fixtures/syntax/class.js index d5f25e2f..b2b7f21f 100644 --- a/src/tests/fixtures/syntax/class.js +++ b/src/tests/fixtures/syntax/class.js @@ -47,13 +47,12 @@ function* a() { async function b() { class A extends (await a()) {} } - const e = 'test'; class O { - #a = 42 + #a = 42; #b() {} - static #c = 'C' - #d + static #c = 'C'; + #d; static { const a = 3; }