Skip to content

Commit 3bae128

Browse files
pedroborgesreinink
andauthored
Fix use:inertia action event listeners types (#2003)
* Fix link action TS * Update changelog --------- Co-authored-by: Jonathan Reinink <jonathan@reinink.ca>
1 parent 2494fd5 commit 3bae128

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ For changes prior to v1.0.0, see the [legacy releases](https://legacy.inertiajs.
1010
## [Unreleased](https://github.com/inertiajs/inertia/compare/v1.3.0-beta.1...HEAD)
1111

1212
- Fix Svelte version import ([#2002](https://github.com/inertiajs/inertia/pull/2002))
13+
- Fix `use:inertia` action event listeners types ([#2003](https://github.com/inertiajs/inertia/pull/2003))
1314

1415
## [v1.3.0-beta.1](https://github.com/inertiajs/inertia/compare/v1.2.0...v1.3.0-beta.1)
1516

packages/svelte/src/link.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ type ActionParameters = Omit<VisitOptions, 'data'> & {
2121
type SelectedEventKeys = 'start' | 'progress' | 'finish' | 'before' | 'cancel' | 'success' | 'error'
2222
type SelectedGlobalEventsMap = Pick<GlobalEventsMap, SelectedEventKeys>
2323
type ActionAttributes = {
24-
[K in keyof SelectedGlobalEventsMap as `on:${K}`]?: CustomEvent<SelectedGlobalEventsMap[K]['details']>
24+
[K in keyof SelectedGlobalEventsMap as `on:${K}` | `on${K}`]?: (
25+
event: CustomEvent<SelectedGlobalEventsMap[K]['details']>,
26+
) => void
2527
} & {
26-
'on:cancel-token'?: CustomEvent<CancelTokenSource>
28+
'on:cancel-token'?: (event: CustomEvent<CancelTokenSource>) => void
29+
oncanceltoken?: (event: CustomEvent<CancelTokenSource>) => void
2730
}
2831

2932
function link(node: ActionElement, options: ActionParameters = {}): ActionReturn<ActionParameters, ActionAttributes> {

0 commit comments

Comments
 (0)