svelte-preprocess
svelte-preprocess copied to clipboard
Components used in Pug cause warning `declared but its value is never read`
Describe the bug
As you can see in the screenshot below, the Svelte VSCode extension does not see that Router and Nested are used inside <Template>. It does however detect that routes was used.

This issue is also mentioned when running svelte-check, so it's not caused by the text editor. My guess is that this is an issue with svelte-preprocess, but may very well be something else.
To Reproduce
Use a component inside a <template lang='pug'> block.
Information about your project:
- Your operating system: macOS 10.14.6
svelte-preprocessversion 4.4.2- Bundler: Svite/Vite
Hey @probablykasper 👋
This seems to be a duplicate of #207
@kaisermann I don't think it is, because in that issue the problem is variables created by Pug. In this case, the variable is created in TypeScript
@kaisermann Got any thoughts on this issue?
@kaisermann Would love to know what could be done about this.
Svelte's Pug support seems quite spotty considering the invalid warnings and errors it generates. Perhaps there should be a note about this if it's not something that's likely to improve anytime soon.
Hey @probablykasper 👋 Unfortunately there's not much I can do from this side (see https://github.com/sveltejs/svelte-preprocess/issues/207#issuecomment-677452657). A comment about the semi-support for pug could be nice, yeah!
@kaisermann I don't quite understand. Is the issue that Pug can't be compiled synchronously?
The problem is that pug does not provide source maps by itself, and that the source mapper we use is asynchronous. We also cannot know which other preprocessors people might mix in, and those could be asynchronous.
@dummdidumm But why would a source map be needed to tell if a component is used or not? I would think that source maps are useful when you have an error and you want to show it in the right place, but not when you have an error that shouldn't exist.
You can turn off diagnostics and not get false errors that way. We could also investigate turning off diagnostics if we detect pug in the template.
@dummdidumm What are the source maps needed for in this case?