Skip to content

Cannot set property 'subscribable' of undefined #2139

Closed
@thgh

Description

@thgh

This happens when referencing a non existent store. The error does not contain any sign of where it is thrown which means it takes a lot of time to fix. One workaround is to open compiler.js:22884 and add if (!variable) console.log('subscribable', name, this.file).

Error is thrown here:

variable.subscribable = true;

Stack trace

Cannot set property 'subscribable' of undefined at Component.add_reference (/Users/thomas/projects/ga/node_modules/svelte/compiler.js:22884:40) at Object.enter (/Users/thomas/projects/ga/node_modules/svelte/compiler.js:21133:36) at visit (/Users/thomas/projects/ga/node_modules/svelte/compiler.js:10204:10) at walk (/Users/thomas/projects/ga/node_modules/svelte/compiler.js:10184:3) at new Expression (/Users/thomas/projects/ga/node_modules/svelte/compiler.js:21094:10) at new EachBlock$1 (/Users/thomas/projects/ga/node_modules/svelte/compiler.js:21547:28) at children.map.child (/Users/thomas/projects/ga/node_modules/svelte/compiler.js:22695:23) at Array.map () at mapChildren (/Users/thomas/projects/ga/node_modules/svelte/compiler.js:22693:22) at new Element$1 (/Users/thomas/projects/ga/node_modules/svelte/compiler.js:21974:26)

Repro: https://v3.svelte.technology/repl?version=3.0.0-beta.8&gist=b154d4f0c5e6d1cc3a03a70a1b7d2350

Same error 2:

<h1>Hello</h1>
<script>
  function test () {
    $name = 2
  }
</script>

Same error 3:

<h1>Hello</h1>
<script>
  $name = 2
</script>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions