Skip to content

Commit 3ee8e0b

Browse files
authored
fix: validation should not fail on anonymous declarations (#13393)
* fix: validation should not fail on anonymous declarations * feedback
1 parent 3d8f987 commit 3ee8e0b

File tree

7 files changed

+14
-2
lines changed

7 files changed

+14
-2
lines changed

.changeset/twelve-bears-worry.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: validation should not fail on anonymous declarations

packages/svelte/src/compiler/phases/2-analyze/visitors/ClassDeclaration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { validate_identifier_name } from './shared/utils.js';
88
* @param {Context} context
99
*/
1010
export function ClassDeclaration(node, context) {
11-
if (context.state.analysis.runes) {
11+
if (context.state.analysis.runes && node.id !== null) {
1212
validate_identifier_name(context.state.scope.get(node.id.name));
1313
}
1414

packages/svelte/src/compiler/phases/2-analyze/visitors/FunctionDeclaration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { validate_identifier_name } from './shared/utils.js';
88
* @param {Context} context
99
*/
1010
export function FunctionDeclaration(node, context) {
11-
if (context.state.analysis.runes) {
11+
if (context.state.analysis.runes && node.id !== null) {
1212
validate_identifier_name(context.state.scope.get(node.id.name));
1313
}
1414

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default class {}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default function () {}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<script>
2+
import func from './function.svelte.js';
3+
import klass from './class.svelte.js';
4+
</script>

0 commit comments

Comments
 (0)