inertiajs / inertia

Inertia.js lets you quickly build modern single-page React, Vue and Svelte apps using classic server-side routing and controllers.
https://inertiajs.com
MIT License
6.56k stars 435 forks source link

Fix `use:inertia` action event listeners types #2003

Closed pedroborges closed 1 month ago

pedroborges commented 1 month ago

Commit 69292ef already took care of the type issue reported in #2001. While looking into the type error, I noticed the custom events needed some adjustment for better type safety.

I also realized the action wasn’t supporting the new Svelte 5 event listener syntax (onbefore), so I’ve added support for both on:before and onstart (and all other events) in this PR.

Before

Svelte 4 syntax (incorrect)

Screen Shot 2024-10-09 at 11 19 49

Svelte 5 syntax (missing)

Screen Shot 2024-10-09 at 11 20 31

After

Svelte 4 syntax

Screen Shot 2024-10-09 at 11 21 01

Svelte 5 syntax

Screen Shot 2024-10-09 at 11 21 10

Closes #2001