Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nine-cups-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: correctly differentiate static fields before emitting `duplicate_class_field`
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ export function ClassBody(node, context) {
e.state_field_duplicate(node, name);
}

const _key = (key.type === 'PrivateIdentifier' ? '#' : '') + name;
const _key =
(node.type === 'AssignmentExpression' || !node.static ? '' : '@') +
(key.type === 'PrivateIdentifier' ? '#' : '') +
name;
const field = fields.get(_key);

// if there's already a method or assigned field, error
Expand Down Expand Up @@ -91,7 +94,10 @@ export function ClassBody(node, context) {
if (child.kind === 'constructor') {
constructor = child;
} else if (!child.computed) {
const key = (child.key.type === 'PrivateIdentifier' ? '#' : '') + get_name(child.key);
const key =
(child.static ? '@' : '') +
(child.key.type === 'PrivateIdentifier' ? '#' : '') +
get_name(child.key);
const field = fields.get(key);
if (!field) {
fields.set(key, [child.kind]);
Expand Down
Loading