Skip to content

Commit

Permalink
fix: static computed property (#672)
Browse files Browse the repository at this point in the history
Co-authored-by: Zack <zack.newsham@gmail.com>
  • Loading branch information
davidbonnet and znewsham authored Dec 21, 2022
1 parent 4ab5737 commit 1630853
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/astring.js
Original file line number Diff line number Diff line change
Expand Up @@ -825,12 +825,22 @@ export const GENERATOR = {
if (node.static) {
state.write('static ')
}
if (node.computed) {
state.write('[')
}
this[node.key.type](node.key, state)
if (node.computed) {
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('{')
Expand Down
8 changes: 5 additions & 3 deletions src/tests/fixtures/syntax/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ 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;
}
static [e] = 123;
}

0 comments on commit 1630853

Please sign in to comment.