Skip to content

Commit 5c14bc5

Browse files
authored
fix: support es2022 class features (#8355)
Follow up to #8349. We also have to bump the parsing ECMAScript version here. Fixes #6900, fixes #6592.
1 parent e2fe8ab commit 5c14bc5

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

src/compiler/parse/acorn.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import * as code_red from 'code-red';
33

44
export const parse = (source: string): Node => code_red.parse(source, {
55
sourceType: 'module',
6-
ecmaVersion: 12,
6+
ecmaVersion: 13,
77
locations: true
88
});
99

1010
export const parse_expression_at = (source: string, index: number): Node => code_red.parseExpressionAt(source, index, {
1111
sourceType: 'module',
12-
ecmaVersion: 12,
12+
ecmaVersion: 13,
1313
locations: true
1414
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* generated by Svelte vX.Y.Z */
2+
import { SvelteComponent, init, safe_not_equal } from "svelte/internal";
3+
4+
function instance($$self) {
5+
class A {
6+
p1;
7+
p2 = 1;
8+
#p3 = 2;
9+
10+
#getP3() {
11+
return this.#p3;
12+
}
13+
}
14+
15+
return [];
16+
}
17+
18+
class Component extends SvelteComponent {
19+
constructor(options) {
20+
super();
21+
init(this, options, instance, null, safe_not_equal, {});
22+
}
23+
}
24+
25+
export default Component;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<script>
2+
class A {
3+
p1;
4+
p2 = 1;
5+
6+
#p3 = 2;
7+
8+
#getP3() {
9+
return this.#p3;
10+
}
11+
}
12+
</script>

0 commit comments

Comments
 (0)