Skip to content

Svelte 5: $props() isn't generic anymore #10812

Closed
@Aloso

Description

@Aloso

Describe the bug

After updating to 5.0.0-next.79, I got type errors in all my components:

<script lang="ts">
  let { foo, bar, baz } = $props<SomeType>()
  //                             ^^^^^^^^^
  // Expected 0 type arguments, but got 1. ts(2558)
</script>

Instead, I need to write this:

  let { foo, bar, baz }: SomeType = $props()

Note that other runes, such as $state(), still support generics.

Reproduction

See above (the error appears in VS Code, but not in the web editor)

Logs

No response

System Info

System:
    OS: Linux 6.6 Manjaro Linux
    CPU: (12) x64 AMD Ryzen 5 5500U with Radeon Graphics
    Memory: 1.77 GB / 7.11 GB
    Container: Yes
    Shell: 5.2.26 - /bin/bash
  Binaries:
    Node: 21.6.1 - /usr/bin/node
    npm: 10.4.0 - /usr/bin/npm
    pnpm: 8.15.4 - /usr/bin/pnpm
  npmPackages:
    svelte: 5.0.0-next.79 => 5.0.0-next.79 
    svelte-check: ^3.6.7 => 3.6.7 
    tslib: ^2.6.2 => 2.6.2 
    typescript: ^5.4.2 => 5.4.2 
    vite: ^5.1.6 => 5.1.6

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions