Skip to content
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

Components used in Pug cause warning declared but its value is never read #266

Open
probablykasper opened this issue Oct 6, 2020 · 10 comments
Assignees

Comments

@probablykasper
Copy link
Contributor

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.
screenshot

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-preprocess version 4.4.2
  • Bundler: Svite/Vite
@kaisermann
Copy link
Member

Hey @probablykasper 👋

This seems to be a duplicate of #207

@kaisermann kaisermann self-assigned this Oct 6, 2020
@probablykasper
Copy link
Contributor Author

@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

@probablykasper
Copy link
Contributor Author

@kaisermann Got any thoughts on this issue?

@probablykasper probablykasper changed the title Used components not Components used in Pug cause warning declared but its value is never read Jan 11, 2021
@probablykasper
Copy link
Contributor Author

@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.

@kaisermann
Copy link
Member

Hey @probablykasper 👋 Unfortunately there's not much I can do from this side (see #207 (comment)). A comment about the semi-support for pug could be nice, yeah!

@probablykasper
Copy link
Contributor Author

@kaisermann I don't quite understand. Is the issue that Pug can't be compiled synchronously?

@dummdidumm
Copy link
Member

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.

@probablykasper
Copy link
Contributor Author

@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.

@dummdidumm
Copy link
Member

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.

@probablykasper
Copy link
Contributor Author

@dummdidumm What are the source maps needed for in this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants