Add better event typing

The any types could probably be improved with $$Generic
This commit is contained in:
Ryan Gossiaux
2022-01-31 21:15:00 -08:00
parent dde8112ca7
commit bfc68577cc
5 changed files with 18 additions and 5 deletions

View File

@@ -70,7 +70,9 @@
export let open: Boolean | undefined = undefined; export let open: Boolean | undefined = undefined;
export let initialFocus: HTMLElement | null = null; export let initialFocus: HTMLElement | null = null;
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher<{
close: boolean;
}>();
let containers: Set<HTMLElement> = new Set(); let containers: Set<HTMLElement> = new Set();
let openClosedState = useOpenClosed(); let openClosedState = useOpenClosed();

View File

@@ -80,7 +80,9 @@
horizontal ? "horizontal" : "vertical" horizontal ? "horizontal" : "vertical"
) as StateDefinition["orientation"]; ) as StateDefinition["orientation"];
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher<{
change: any;
}>();
let listboxState: StateDefinition["listboxState"] = ListboxStates.Closed; let listboxState: StateDefinition["listboxState"] = ListboxStates.Closed;
let labelRef: StateDefinition["labelRef"] = writable(null); let labelRef: StateDefinition["labelRef"] = writable(null);

View File

@@ -66,7 +66,9 @@
let id = `headlessui-radiogroup-${useId()}`; let id = `headlessui-radiogroup-${useId()}`;
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher<{
change: any;
}>();
let api: Writable<StateDefinition> = writable({ let api: Writable<StateDefinition> = writable({
options, options,

View File

@@ -17,7 +17,9 @@
export let as: SupportedAs = "button"; export let as: SupportedAs = "button";
export let use: HTMLActionArray = []; export let use: HTMLActionArray = [];
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher<{
change: boolean;
}>();
export let checked = false; export let checked = false;
let api = useSwitchContext(); let api = useSwitchContext();
let labelContext = useLabelContext(); let labelContext = useLabelContext();

View File

@@ -38,7 +38,12 @@
export let leaveFrom = ""; export let leaveFrom = "";
export let leaveTo = ""; export let leaveTo = "";
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher<{
afterEnter: null;
afterLeave: null;
beforeEnter: null;
beforeLeave: null;
}>();
let container: HTMLElement | null = null; let container: HTMLElement | null = null;