Skip to content

Svelte 5: Assignment to a private non-reactive property of a class in a .svelte.ts file will throw an error #9404

@AhmadMayo

Description

@AhmadMayo

Describe the bug

1- create a .svelte.ts or .svelte.js file
2- create a class with a private non-reactive property (doesn't matter if it's initialized or not)
3- assign a value to the private (in the constructor or in a method)
4- import the class into a svelte file and initialize it

A compilation error is thrown

[vite] Error when evaluating SSR module /src/routes/+page.svelte: failed to import "/src/routes/test.svelte.ts"
|- TypeError: Cannot read properties of undefined (reading 'includes')
    at validate_assignment (file:///test-svelte-5/node_modules/svelte/src/compiler/phases/2-analyze/validation.js:605:35)
    at AssignmentExpression (file:///test-svelte-5/node_modules/svelte/src/compiler/phases/2-analyze/validation.js:550:3)
    at go (file:///$test-svelte-5/node_modules/svelte/src/compiler/phases/visitors.js:49:5)
    at visitor (file:///test-svelte-5/node_modules/svelte/src/compiler/phases/visitors.js:64:4)
    at Object.next (file:///test-svelte-5/node_modules/zimmerframe/src/walk.js:106:21)
    at go (file:///test-svelte-5/node_modules/svelte/src/compiler/phases/visitors.js:45:29)
    at next (file:///test-svelte-5/node_modules/svelte/src/compiler/phases/visitors.js:55:7)
    at _ (file:///test-svelte-5/node_modules/svelte/src/compiler/phases/scope.js:666:4)
    at go (file:///test-svelte-5/node_modules/svelte/src/compiler/phases/visitors.js:49:5)
    at visitor (file:///test-svelte-5/node_modules/svelte/src/compiler/phases/visitors.js:64:4)

Copying the same code to a .svelte file doesn't reproduce the error.

Note that I created the application using npm create svelte@next test-svelte-5, and then I updated svelte to next. I don't know if I need to update any dependencies other than svelte or not.

Reproduction

reproduction

Logs

[vite] Error when evaluating SSR module /src/routes/+page.svelte: failed to import "/src/routes/test.svelte.ts"
|- TypeError: Cannot read properties of undefined (reading 'includes')
    at validate_assignment (file:///test-svelte-5/node_modules/svelte/src/compiler/phases/2-analyze/validation.js:605:35)
    at AssignmentExpression (file:///test-svelte-5/node_modules/svelte/src/compiler/phases/2-analyze/validation.js:550:3)
    at go (file:///$test-svelte-5/node_modules/svelte/src/compiler/phases/visitors.js:49:5)
    at visitor (file:///test-svelte-5/node_modules/svelte/src/compiler/phases/visitors.js:64:4)
    at Object.next (file:///test-svelte-5/node_modules/zimmerframe/src/walk.js:106:21)
    at go (file:///test-svelte-5/node_modules/svelte/src/compiler/phases/visitors.js:45:29)
    at next (file:///test-svelte-5/node_modules/svelte/src/compiler/phases/visitors.js:55:7)
    at _ (file:///test-svelte-5/node_modules/svelte/src/compiler/phases/scope.js:666:4)
    at go (file:///test-svelte-5/node_modules/svelte/src/compiler/phases/visitors.js:49:5)
    at visitor (file:///test-svelte-5/node_modules/svelte/src/compiler/phases/visitors.js:64:4)

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
    CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
    Memory: 4.49 GB / 7.67 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 20.9.0 - ~/.asdf/installs/nodejs/20.9.0/bin/node
    npm: 10.1.0 - ~/.asdf/plugins/nodejs/shims/npm
  npmPackages:
    svelte: ^5.0.0-next.1 => 5.0.0-next.1

Severity

blocking an upgrade

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions