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

async prepended to <script> html tag when using vscode quick fix #2669

Open
CuriousCodingCanadian opened this issue Jan 18, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@CuriousCodingCanadian
Copy link

CuriousCodingCanadian commented Jan 18, 2025

Describe the bug

When using Svelte for VS Code, if you use await in a non-async non-function context outside the top level (i.e. for loop, if statement, block), and use the Quick Fix "Add async modifier to containing function", the script tag will be changed from <script ...> to <async script ...>.

Reproduction

Write the following code in a Svelte file:

<script lang="ts">
console.log("top level");
{
    await new Promise((resolve) => setTimeout(resolve, 1));
}
</script>

The await keyword will be underlined with a red squiggly line. Hover over it, select "Quick fix", then "Add async modifier to containing function".

The containing script tag will be replaced with <async script lang="ts">.

Expected behaviour

Either do not show the option to add async modifier to containing function in this context, or wrap the current context in a function or IIFE.

System Info

  • OS: Arch Linux
  • IDE: VSCode

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

Image

@CuriousCodingCanadian CuriousCodingCanadian added the bug Something isn't working label Jan 18, 2025
@CuriousCodingCanadian CuriousCodingCanadian changed the title await prepended to <script> html tag when using vscode quick fix async prepended to <script> html tag when using vscode quick fix Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant