From 0ac22c19b213822a0de90c516e523dc22164ca13 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 15 May 2025 15:02:58 -0400 Subject: [PATCH] failing test --- .../samples/class-state-constructor-9/errors.json | 14 ++++++++++++++ .../class-state-constructor-9/input.svelte.js | 9 +++++++++ 2 files changed, 23 insertions(+) create mode 100644 packages/svelte/tests/validator/samples/class-state-constructor-9/errors.json create mode 100644 packages/svelte/tests/validator/samples/class-state-constructor-9/input.svelte.js diff --git a/packages/svelte/tests/validator/samples/class-state-constructor-9/errors.json b/packages/svelte/tests/validator/samples/class-state-constructor-9/errors.json new file mode 100644 index 0000000000..6cdeb4a14e --- /dev/null +++ b/packages/svelte/tests/validator/samples/class-state-constructor-9/errors.json @@ -0,0 +1,14 @@ +[ + { + "code": "constructor_state_reassignment", + "message": "A state field declaration in a constructor must be the first assignment, and the only one that uses a rune", + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 24 + } + } +] diff --git a/packages/svelte/tests/validator/samples/class-state-constructor-9/input.svelte.js b/packages/svelte/tests/validator/samples/class-state-constructor-9/input.svelte.js new file mode 100644 index 0000000000..e5ad562727 --- /dev/null +++ b/packages/svelte/tests/validator/samples/class-state-constructor-9/input.svelte.js @@ -0,0 +1,9 @@ +export class Counter { + constructor() { + if (true) { + this.count = -1; + } + + this.count = $state(0); + } +}