@atom-forge/svelte-helpers · Svelte 5
Svelte Helpers provides prop types, TypeScript constraints, runtime utilities and a snippet-rendering component for Svelte 5. Use it alongside Svelte’s own types; it does not replace the framework’s reactivity.
What it is
ClassProp, ChildrenProp and ChildrenPropOptional describe the common props. XOR expresses mutually exclusive variants and AtLeastOne requires at least one of a set of properties.
At runtime there are variantMap for boolean variants, debounce and debounceAsync, an as helper for deliberate type assertions, and RenderSnippet for rendering snippets where a component is expected.
XOR and AtLeastOne make invalid combinations a compile-time error.
The children types match Svelte 5 {@render ...}, not legacy slots.
Contracts are imported with import type, so they add nothing to the bundle.
Combine ClassProp and ChildrenProp with your own props.
Use XOR for exclusive options and variantMap to turn them into one value.
Use $derived for values that must follow changing props.
An honest fit check
XOR, AtLeastOne and type assertions do not validate runtime input.
The helpers assume runes and snippets and are not a drop-in for older Svelte projects.
Type contracts adapted from the package guide.
import type { XOR, AtLeastOne } from '@atom-forge/svelte-helpers';
type SizeProps = XOR<{ small: true }, { compact: true }, {}>;
type Contact = AtLeastOne<{ email: string; phone: string }>;
const compact: SizeProps = { compact: true };
const contact: Contact = { email: 'ada@example.test' };