Skip to content

Svelte typescript parsing #14180

@jkasak

Description

@jkasak

Summary

In a <script lang="ts"> inside a .svelte file, compound inline type definitions like Node[] in the example below seem to break something in the grammar.

Image

This manifests in both the function name not receiving syntax highlighting, but also broken matching on parens/brackets/curlies.

After a hx --grammar fetch and hx --grammar build

# hx --health svelte
Configured language servers:
  ✓ svelteserver: /opt/homebrew/bin/svelteserver
Configured debug adapter: None
Configured formatter:
  ✓ /opt/homebrew/bin/prettier
Tree-sitter parser: ✓
Highlight queries: ✓
Textobject queries: ✘
Indent queries: ✓

This bug does not appear in regular .ts files.

Reproduction Steps

I tried this:

  1. hx
  2. Create a .svelte file with a typescript injection.
<script lang="ts">
  let count = $state(0);
  const doubled = $derived(count * 2);

  function increment(): void {
    count += 1;
  }
</script>

<main>
  <p>
    The count is {count}
  </p>
  <p>
    Doubled, the count is {doubled}
  </p>

  <button onclick={increment}>
    Increment
  </button>
</main>
  1. This renders nicely
Image
  1. Modify increment function type
<script lang="ts">
  let count = $state(0);
  const doubled = $derived(count * 2);

  function increment({messages}: {messages: string[]}): void {
    messages.map(console.log)
    count += 1;
  }
</script>

<main>
  <p>
    The count is {count}
  </p>
  <p>
    Doubled, the count is {doubled}
  </p>

  <button onclick={() => increment({messages:["hello"]})}>
    Increment
  </button>
</main>
  1. Rendering and parens matching broken
Image

I expected this to happen:
Rendering and parens matching should still have worked.

Instead, this happened:
It did not work.

Helix log

~/.cache/helix/helix.log 2025-08-07T12:35:34.385 helix_view::document [ERROR] Formatter error: [error] Couldn't resolve parser "svelte".

Looks relevant.

Platform

macOs

Terminal Emulator

ghostty

Installation Method

brew

Helix Version

helix 25.07.1 (a05c151)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions