Skip to content

Commit

Permalink
Add better event typing
Browse files Browse the repository at this point in the history
The any types could probably be improved with $$Generic
  • Loading branch information
rgossiaux committed Feb 1, 2022
1 parent dde8112 commit bfc6857
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/lib/components/dialog/Dialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@
export let open: Boolean | undefined = undefined;
export let initialFocus: HTMLElement | null = null;
const dispatch = createEventDispatcher();
const dispatch = createEventDispatcher<{
close: boolean;
}>();
let containers: Set<HTMLElement> = new Set();
let openClosedState = useOpenClosed();
Expand Down
4 changes: 3 additions & 1 deletion src/lib/components/listbox/Listbox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@
horizontal ? "horizontal" : "vertical"
) as StateDefinition["orientation"];
const dispatch = createEventDispatcher();
const dispatch = createEventDispatcher<{
change: any;
}>();
let listboxState: StateDefinition["listboxState"] = ListboxStates.Closed;
let labelRef: StateDefinition["labelRef"] = writable(null);
Expand Down
4 changes: 3 additions & 1 deletion src/lib/components/radio-group/RadioGroup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@
let id = `headlessui-radiogroup-${useId()}`;
const dispatch = createEventDispatcher();
const dispatch = createEventDispatcher<{
change: any;
}>();
let api: Writable<StateDefinition> = writable({
options,
Expand Down
4 changes: 3 additions & 1 deletion src/lib/components/switch/Switch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
export let as: SupportedAs = "button";
export let use: HTMLActionArray = [];
const dispatch = createEventDispatcher();
const dispatch = createEventDispatcher<{
change: boolean;
}>();
export let checked = false;
let api = useSwitchContext();
let labelContext = useLabelContext();
Expand Down
7 changes: 6 additions & 1 deletion src/lib/components/transitions/TransitionChild.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@
export let leaveFrom = "";
export let leaveTo = "";
const dispatch = createEventDispatcher();
const dispatch = createEventDispatcher<{
afterEnter: null;
afterLeave: null;
beforeEnter: null;
beforeLeave: null;
}>();
let container: HTMLElement | null = null;
Expand Down

0 comments on commit bfc6857

Please sign in to comment.