Skip to content

Svelte 5: Action parameters type inferred as 'any' despite explicit typingΒ #13268

@colinlienard

Description

@colinlienard

Describe the bug

When defining an Action with explicit parameter types, the compiler still infers the parameters as any, leading to type errors when accessing properties:

image

But this seems to happen only in the IDE because when running svelte-check there are no errors.

Reproduction

https://github.com/colinlienard/svelte-5-repro in src/App.svelte

Logs

Property 'foo' does not exist on type 'unknown'

System Info

System:
    OS: macOS 14.6.1
    CPU: (8) arm64 Apple M2
    Memory: 505.70 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.0 - ~/.nvm/versions/node/v20.11.0/bin/node
    Yarn: 1.22.21 - ~/.nvm/versions/node/v20.11.0/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.0/bin/npm
    pnpm: 9.0.6 - ~/.nvm/versions/node/v20.11.0/bin/pnpm
    bun: 1.1.26 - ~/.nvm/versions/node/v20.11.0/bin/bun
  Browsers:
    Chrome: 128.0.6613.138
    Safari: 17.6
  npmPackages:
    svelte: 5.0.0-next.246 => 5.0.0-next.246

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions