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

[TypeScript] Declaring variable as type, without a value, without a semicolon, as the last item in the <script>, messes up syntax highlighting in VS Code #1993

Closed
D-Marc1 opened this issue Apr 23, 2023 · 1 comment
Labels
duplicate This issue or pull request already exists upstream

Comments

@D-Marc1
Copy link

D-Marc1 commented Apr 23, 2023

Describe the bug

Declaring the final item in the <script> as a type, without setting a value, without a semicolon, messes up the syntax highlighter:

<script lang="ts">
export let name: string
</script>

<p>{name}</p>

Reproduction

Say I have the following Svelte file:

<script lang="ts">
export let name: string
</script>

<p>{name}</p>

This will mess up the syntax highlighting.

However, the syntax highlighting is fixed by setting a default value to the variable, using a semicolon or setting a variable to a value under it:

Setting default value to variable

<script lang="ts">
export let name = ''
</script>

<p>{name}</p>

Using a semicolon

<script lang="ts">
export let name: string;
</script>

<p>{name}</p>

Setting default value to a variable as the last item in the <script>

<script lang="ts">
export let name: string
export let count = 0
</script>

<p>{name}</p>

Notice how even on GitHub's syntax highlighter, you can see the difference between by first example and last 3 ones.

Expected behaviour

The expected behavior is that declaring a variable as a type as the last item in the <script>, without setting it to value, without semicolons, shouldn't break the syntax highlighting.

System Info

  • OS: MacOS
  • IDE: VSCode

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

Syntax highlighting breaking

Screen Shot 2023-04-23 at 1 18 03 PM

Syntax highlighting working

Screen Shot 2023-04-23 at 1 18 26 PM

@D-Marc1 D-Marc1 added the bug Something isn't working label Apr 23, 2023
@jasonlyu123
Copy link
Member

Duplicate of #1970

@jasonlyu123 jasonlyu123 marked this as a duplicate of #1970 Apr 23, 2023
@jasonlyu123 jasonlyu123 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 23, 2023
@jasonlyu123 jasonlyu123 added duplicate This issue or pull request already exists upstream and removed bug Something isn't working labels Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists upstream
Projects
None yet
Development

No branches or pull requests

2 participants