question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: Using the auto-subscription syntax for a store that was defined in the context="module" script yields an error.

See original GitHub issue

Take a look at the Test component in the following REPL: https://svelte.dev/repl/4859affa8c1c436783a9d9a6d537c903?version=3

A store is created in a context="module" script tag, and it’s being used with a dollar sign $ prepended to it, in the markup. It works as expected. However, the very same code in VS Code shows an error:

image

Note that it works and compiles properly, in other words, the compiler gives no errors; so it must be the Svelte VS Code extension that’s the problem, basically it doesn’t properly recognize any store that’s been defined in the context="module" script, and as a result causing a red squiggly to appear under $count here.

Also, it’s only when the lang="ts" attribute is present on the <script> tag that the red squiggly appears.

I’d appreciate it if this can be fixed soon.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
dummdidummcommented, Mar 3, 2021

Using the auto-subscription syntax for a store that was defined in the context=“module” script should no longer yield an error as of VS Code extension 104.6.0 / svelte-check 1.2.1

2reactions
fivemrucommented, Mar 3, 2021
  1. Faced the same problem. Error: Cannot find name '$username'. Did you mean 'username'? (ts) when username created in context="module".

image

  1. There is one more error when running svelte-check:
> svelte-check --ignore src/node_modules/@sapper

/src/routes/my/test.svelte:2:2
Hint: '$username' is declared but its value is never read. (ts)
<script lang="ts">
  import { username } from './_store';

Code: image

Version:

    "svelte": "^3.35.0",
    "svelte-check": "^1.2.0",
    "typescript": "^4.2.2"
Read more comments on GitHub >

github_iconTop Results From Across the Web

v4.9 broke accessing stores with $ prefix when imported in ...
Hey, everywhere in my code where I access store values using the $ prefix now cause an is not defined error similar to...
Read more >
NetSuite Applications Suite - N/error Module
Source Code Editing to Customize Advanced Templates · Syntax for Advanced Template Fields · Setting a Template to Use a Font Unavailable in...
Read more >
SvelteKit: Cannot reference store value inside <script context ...
but manually calling store methods is ok ( mystore. set(…) and get(mystore). value ). Here's a github issue with an example.
Read more >
Database Engine events and errors - SQL Server
Consult this MSSQL error code list to find explanations for error messages for SQL Server database engine events.
Read more >
Docs • Svelte
A <script> tag with a context="module" attribute runs once when the module first evaluates, rather than for each component instance. Values declared in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found