-
-
Notifications
You must be signed in to change notification settings - Fork 209
Diagnostic message "Stores must be declared at the top level of the component" gives invalid line number #1271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Did you disable sourcemap for preprocessing by any means? It seems like this diagnostic can't be mapped back to its source. |
Not as far as I know but I'm happy to run any kind of check on my end. This is the only diagnostic that has a problem--everything else works correctly. |
I installed VSCode to rule out anything specific to my neovim setup. I installed the svelte extension, opened up a fresh directory, made a new file, and pasted in the code in my report. While I'm not sure how to debug the underlying LSP like I am with nvim, it looks like it's broken here as well: as long as this error is in the file, the problems elsewhere in the file don't update. You can insert gibberish into the file and it will only suddenly be flagged as a problem once you remove the console.log($bar) line or otherwise fix that error. Additionally I ran into a second diagnostic where this happens:
If I add a second line with gibberish like Finally it looks like this is related to the |
Did you have a If you do have a |
Aha, you're right. I added a tsconfig.json (extending the @tsconfig/svelte config) and these diagnostics work now. Thanks! That fixes my problem, though I still consider this a bug--if the language server runs into problems like this it should fail more gracefully than sending invalid diagnostics. |
Does a version bump help us, or is this something that's still a problem inside 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 }
}
})
}; |
It's fixed in sveltejs/svelte-preprocess#407
Yeah we also should fix the line number. |
Ts, svelte-preprocess, prettier sveltejs#1271
Ts, svelte-preprocess, prettier #1271
#1271 This would still happen if somehow the user explicitly disabled the ts sourcemap or there's other source map issues.
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:
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):
The text was updated successfully, but these errors were encountered: