-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
export enum
in Typescript ends up producing a Svelte compiler warning
#7055
Comments
Here's how I'm dealing with this in plugins: [
svelte({
/* ... */
onwarn: (warning, handler) => {
const exportedEnums = ['InteractiveTreeFlags'];
const { code, frame } = warning;
const mentionsEnum = () =>
exportedEnums.reduce((found, name) => (found || frame.includes(name)), false);
if (code == "unused-export-let" && mentionsEnum()) {
return;
}
handler(warning);
}
}), |
rgossiaux
added a commit
to rgossiaux/svelte
that referenced
this issue
Feb 7, 2022
Fixes sveltejs#7055 I think this might be the best way to fix the linked issue, and I think it's a reasonable change. Since code inside <script context="module"> is basically just regular JS, warnings like this can be delegated to userland tools--I don't think it needs to be the Svelte compiler's business especially when these compiler warnings cannot be ignored inline.
5 tasks
himanshiLt
pushed a commit
to himanshiLt/svelte
that referenced
this issue
Mar 3, 2022
…"> (sveltejs#7232) Fixes sveltejs#7055. This warning can be delegated to userland tools like eslint
This should be fixed in 3.46.5. |
Thank you! I was able to delete my |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
I'm not at all confident that this issue belongs in this repo, since it could plausibly go into several different ones, but I thought I'd file it here to begin with since it's ultimately the Svelte compiler which is generating the warning and there is no way to ignore it (adding the ability to silence individual compiler warnings like this in JS, similar to the
<!-- svelte-ignore -->
template comment, would be one way of resolving this).Anyway, the issue: Typescript code with
export enum
from inside<script context="module" lang="ts">
block ends up generating anunused-export-let
warning; see sveltejs/language-tools#573 While the language-tools project added special handling to deal with this as an editor warning, it still generates warnings in other parts of the ecosystem. Users of my library may see this from vite-plugin-svelte, for example: rgossiaux/svelte-headlessui#25Besides the ability to silence the warning, alternate resolutions could be:
Reproduction
It's not a minimal repo, but you can repo this by installing https://github.com/rgossiaux/svelte-headlessui and running
npm run dev
. But I think something very basic should work too, along the lines ofLogs
No response
System Info
System: OS: macOS 12.1 CPU: (10) arm64 Apple M1 Max Memory: 26.12 GB / 64.00 GB Shell: 3.3.1 - /opt/homebrew/bin/fish Binaries: Node: 16.8.0 - /var/folders/rn/2kdgb0jj25q2v656j3qc_ywr0000gn/T/fnm_multishells/23662_1640400023652/bin/node Yarn: 1.22.17 - /opt/homebrew/bin/yarn npm: 7.21.0 - /var/folders/rn/2kdgb0jj25q2v656j3qc_ywr0000gn/T/fnm_multishells/23662_1640400023652/bin/npm Browsers: Chrome: 96.0.4664.110 Safari: 15.2 npmPackages: svelte: ^3.44.0 => 3.44.3
Severity
annoyance
The text was updated successfully, but these errors were encountered: