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

@const with left shift causes issue in VSCode #1499

Closed
mwhebert opened this issue May 27, 2022 · 1 comment
Closed

@const with left shift causes issue in VSCode #1499

mwhebert opened this issue May 27, 2022 · 1 comment
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.

Comments

@mwhebert
Copy link

mwhebert commented May 27, 2022

Describe the bug

In VSCode the file contents below will cause an error stating: "Type annotations can only be used in TypeScript files.js(8010)" even though the script tag includes lang="ts". This will show up on the "type" declaration "export let labels: string[];" line where "string[]" will have the red squiggle line below it.

Moving the "left shift" out of the @const and calling it in a function works around the issue.
ex: {@const mask = doShift(1,indx)}

I assume it has to do with parsing inside the "html" section the "<" is causing the issue.

The file will compile and work, this seems to be just an issue with the plugin.

Reproduction

<script lang="ts">
  export let labels: string[];
</script>

<div>
  {#each labels as label, indx}
    {@const mask = 1 << indx}
    <div>
      <span>{label} {mask}</span>
    </div>
  {/each}
</div>

Expected behaviour

I would assume no error displayed under the "string[]" type declaration.

System Info

OS: [Windows 11]
IDE: [VSCode 1.67.2]

Svelte for VS Code: v105.16.1

Which package is the issue about?

Svelte for VS Code

Additional Information, eg. Screenshots

image

@mwhebert mwhebert added the bug Something isn't working label May 27, 2022
@dummdidumm
Copy link
Member

This is probably working as expected with the new transformation, so I'm hesitant to fix it for the (not much longer) old transformation.

dummdidumm pushed a commit to dummdidumm/language-tools that referenced this issue Jun 15, 2022
@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Jun 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.
Projects
None yet
Development

No branches or pull requests

2 participants