Skip to content

Commit

Permalink
fix: support class exports (#9465)
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm committed Nov 15, 2023
1 parent 6f3dc04 commit 9ef3424
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/thirty-flowers-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: support class exports
10 changes: 8 additions & 2 deletions packages/svelte/src/compiler/phases/2-analyze/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,10 @@ const legacy_scope_tweaker = {
return next();
}

if (node.declaration.type === 'FunctionDeclaration') {
if (
node.declaration.type === 'FunctionDeclaration' ||
node.declaration.type === 'ClassDeclaration'
) {
state.analysis.exports.push({
name: /** @type {import('estree').Identifier} */ (node.declaration.id).name,
alias: null
Expand Down Expand Up @@ -681,7 +684,10 @@ const runes_scope_tweaker = {
return next();
}

if (node.declaration.type === 'FunctionDeclaration') {
if (
node.declaration.type === 'FunctionDeclaration' ||
node.declaration.type === 'ClassDeclaration'
) {
state.analysis.exports.push({
name: /** @type {import('estree').Identifier} */ (node.declaration.id).name,
alias: null
Expand Down
9 changes: 0 additions & 9 deletions packages/svelte/src/compiler/phases/2-analyze/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,15 +453,6 @@ export const validation_legacy = merge(validation, a11y_validators, {
// TODO check if it's a store subscription that's called? How likely is it that someone uses a store that contains a function?
error(node.init, 'invalid-rune-usage', callee.name);
},
ExportNamedDeclaration(node) {
if (
node.declaration &&
node.declaration.type !== 'VariableDeclaration' &&
node.declaration.type !== 'FunctionDeclaration'
) {
error(node, 'TODO', 'whatever this is');
}
},
AssignmentExpression(node, { state, path }) {
const parent = path.at(-1);
if (parent && parent.type === 'ConstTag') return;
Expand Down

1 comment on commit 9ef3424

@vercel
Copy link

@vercel vercel bot commented on 9ef3424 Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

svelte-5-preview – ./sites/svelte-5-preview

svelte-5-preview.vercel.app
svelte-octane.vercel.app
svelte-5-preview-svelte.vercel.app
svelte-5-preview-git-main-svelte.vercel.app

Please sign in to comment.