Skip to content

Commit ba274bf

Browse files
committed
fix: support class exports
1 parent 6f3dc04 commit ba274bf

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

.changeset/thirty-flowers-sit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: support class exports

packages/svelte/src/compiler/phases/2-analyze/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,10 @@ const legacy_scope_tweaker = {
577577
return next();
578578
}
579579

580-
if (node.declaration.type === 'FunctionDeclaration') {
580+
if (
581+
node.declaration.type === 'FunctionDeclaration' ||
582+
node.declaration.type === 'ClassDeclaration'
583+
) {
581584
state.analysis.exports.push({
582585
name: /** @type {import('estree').Identifier} */ (node.declaration.id).name,
583586
alias: null
@@ -681,7 +684,10 @@ const runes_scope_tweaker = {
681684
return next();
682685
}
683686

684-
if (node.declaration.type === 'FunctionDeclaration') {
687+
if (
688+
node.declaration.type === 'FunctionDeclaration' ||
689+
node.declaration.type === 'ClassDeclaration'
690+
) {
685691
state.analysis.exports.push({
686692
name: /** @type {import('estree').Identifier} */ (node.declaration.id).name,
687693
alias: null

packages/svelte/src/compiler/phases/2-analyze/validation.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -453,15 +453,6 @@ export const validation_legacy = merge(validation, a11y_validators, {
453453
// TODO check if it's a store subscription that's called? How likely is it that someone uses a store that contains a function?
454454
error(node.init, 'invalid-rune-usage', callee.name);
455455
},
456-
ExportNamedDeclaration(node) {
457-
if (
458-
node.declaration &&
459-
node.declaration.type !== 'VariableDeclaration' &&
460-
node.declaration.type !== 'FunctionDeclaration'
461-
) {
462-
error(node, 'TODO', 'whatever this is');
463-
}
464-
},
465456
AssignmentExpression(node, { state, path }) {
466457
const parent = path.at(-1);
467458
if (parent && parent.type === 'ConstTag') return;

0 commit comments

Comments
 (0)