fix: support class exports (#9465)

pull/9471/head
Simon H 1 year ago committed by GitHub
parent 6f3dc04c82
commit 9ef3424732
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: support class exports

@ -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
@ -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

@ -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;

Loading…
Cancel
Save