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.

Diagnostic message "Stores must be declared at the top level of the component" gives invalid line number

See original GitHub issue

Describe the bug The diagnostic message Stores must be declared at the top level of the component comes with a line number of -1, which is invalid: https://microsoft.github.io/language-server-protocol/specification#position This breaks diagnostics in my editor.

To Reproduce Here is a minimal file that repros this for me:

<script lang="ts">
    import { writable } from "svelte/store";

    let foo = writable("value");
    function bar() {
        let bar = foo;
        console.log($bar);
    }
</script>

Expected behavior The line number should ideally be the line number of the underlying problem, but at the very least (if this is an upstream svelte problem) it should be validated to be non-negative, eg setting it to 0.

Screenshots If applicable, add screenshots to help explain your problem.

System (please complete the following information):

  • OS: Mac OS 12.0
  • IDE: Neovim
  • Plugin/Package: svelte-language-server 0.14.13

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jasonlyu123commented, Dec 10, 2021

Does a version bump help us

It’s fixed in https://github.com/sveltejs/svelte-preprocess/pull/407

though I still consider this a bug–if the language server runs into problems like this it should fail more gracefully than sending invalid diagnostic

Yeah we also should fix the line number.

0reactions
dummdidummcommented, Dec 10, 2021

Did you have a tsconfig.json or jsconfig.json? From my debugging, it seems like the version of the svelte-preprocess we’re bundling doesn’t quite work when there isn’t either of them. The forced sourcemap option we passed also doesn’t work. We might have to consider bumping the version.

Does a version bump help us, or is this something that’s still a problem inside svelte-preprocess? Or is it just a configuration problem on our end? Maybe we need to pass sourceMap: true as well?

        return {
            preprocess: sveltePreprocess({
                sourceMap: true, //<<-- add this line
                // 4.x does not have transpileOnly anymore, but if the user has version 3.x
                // in his repo, that one is loaded instead, for which we still need this.
                typescript: <any>{
                    transpileOnly: true,
                    compilerOptions: { sourceMap: true, inlineSourceMap: false }
                }
            })
        };
Read more comments on GitHub >

github_iconTop Results From Across the Web

Diagnostic messages - Dart
This page lists diagnostic messages produced by the Dart analyzer, with details about what those messages mean and how you can fix your...
Read more >
Common error messages in SAS | SAS Learning Modules
The first NOTE says that the data for variable "a" is invalid in line 2311 position 1-4. Since line 2310 is the line...
Read more >
Settings Reference for Python - Visual Studio Code
Diagnostics for imports that have no corresponding source file. This happens when a type stub is found, but the module source file was...
Read more >
Debugging code - Roku Developer
Debugger message: "'Dot' Operator attempted with invalid BrightScript Component or interface reference". This message will often coincide with a blank screen.
Read more >
Documentation: 15: 43.6. Control Structures - PostgreSQL
But to return a composite (row) value, you must write an expression delivering ... If control reaches the end of the top-level block...
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