Fix more TS errors in strict mode
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { useSwitchContext } from "./SwitchGroup.svelte";
|
||||
import type { LabelContext } from "$lib/components/label/LabelProvider.svelte";
|
||||
import {
|
||||
DescriptionContext,
|
||||
useDescriptionContext,
|
||||
} from "$lib/components/description/DescriptionProvider.svelte";
|
||||
import { useDescriptionContext } from "$lib/components/description/DescriptionProvider.svelte";
|
||||
import { useId } from "$lib/hooks/use-id";
|
||||
import { Keys } from "$lib/utils/keyboard";
|
||||
import { getContext, createEventDispatcher } from "svelte";
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
}
|
||||
|
||||
const SWITCH_CONTEXT_NAME = "SwitchContext";
|
||||
export function useSwitchContext():
|
||||
| Writable<StateDefinition | undefined>
|
||||
| undefined {
|
||||
export function useSwitchContext(): Writable<StateDefinition> | undefined {
|
||||
return getContext(SWITCH_CONTEXT_NAME);
|
||||
}
|
||||
</script>
|
||||
@@ -19,18 +17,16 @@
|
||||
|
||||
let switchStore: Writable<HTMLButtonElement | null> = writable(null);
|
||||
|
||||
let api: Writable<StateDefinition | undefined> = writable();
|
||||
setContext("SwitchApi", api);
|
||||
let api: Writable<StateDefinition | undefined> = writable({
|
||||
switchStore,
|
||||
});
|
||||
setContext(SWITCH_CONTEXT_NAME, api);
|
||||
|
||||
function onClick() {
|
||||
if (!$switchStore) return;
|
||||
$switchStore.click();
|
||||
$switchStore.focus({ preventScroll: true });
|
||||
}
|
||||
|
||||
$: api.set({
|
||||
switchStore,
|
||||
});
|
||||
</script>
|
||||
|
||||
<div {...$$restProps}>
|
||||
|
||||
Reference in New Issue
Block a user