Open
Description
Describe the problem
This has been a common problem in Svelte for long. I like the currently cooking attachments (#15000) PR that aims to solve this, but I think deprecating transitions/other directives won't happen very soon, and a solution for them would be nice.
Describe the proposed solution
Attachments can be applied using symbols. I don't like that any symbol is treated as an attachment - string props are already all used, and using all symbols disallows adding additional stuff in the future. Why not...
<script>
import { Bind, Transition, Use } from "svelte/symbols"
const boundProps = $state({ ... })
const props = {
[Bind]: boundProps,
[Transition]: [fade, { duration: 1000 }],
[Use]: ...
}
</script>
<Component {...props} />
<!-- Component.svelte -->
<script>
let { a = 5, b = $bindable(), ...rest } = $props()
</script>
<div {...rest} >
...
</div>
where svelte/symbols is something like:
export const Transition = Symbol.for("svelte:transition")
...
I think typescript also plays nice with such symbols.
Importance
nice to have
Metadata
Metadata
Assignees
Labels
No labels