Skip to content

Component with generic type - type is not constrained #15136

@patrickiel

Description

@patrickiel

Describe the bug

Generic type parameter in a component is not properly constrained, allowing any type to be passed when using the component, potentially leading to type safety issues. This allows invalid types to be passed without triggering type errors.

Expected Behavior

  • The generic type parameter should be properly constrained
  • Enforced type safety when using the component
  • Invalid types should trigger type errors during development

Reproduction

https://svelte.dev/playground/0aaba3651e6b4cf183a0cf73d539dbb4?version=5.19.4
(same behaviour in VSCode with the extension "Svelte for VS Code")

  • Define a component with a generic type parameter
  • Attempt to use the component with various types
  • Observe that any type is accepted without constraint

Logs

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 AMD Ryzen 7 7700X 8-Core Processor
    Memory: 14.39 GB / 31.10 GB
  Binaries:
    Node: 23.6.1 - C:\Program Files\nodejs\node.EXE
    npm: 10.9.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (131.0.2903.99)
    Internet Explorer: 11.0.26100.1882

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