// Based off `svelte-typed-context` // https://github.com/KamenKolev/svelte-typed-context import { getContext as svelteGetContext, hasContext as svelteHasContext, setContext as svelteSetContext, } from 'svelte' import * as KEYS from './keys' export { KEYS } // Provided as key to getContext and setContext in order to enable strict typing // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-object-type export interface ContextKey {} declare const _checked: unique symbol interface CheckedInjectionKey extends ContextKey { [_checked]?: never } type getContext = { (key: CheckedInjectionKey): T (key: ContextKey): undefined | T } type setContext = (key: ContextKey, context: T) => void type hasContext = (key: ContextKey) => key is CheckedInjectionKey export const getContext = svelteGetContext as getContext export const setContext = svelteSetContext as setContext export const hasContext = svelteHasContext as hasContext