Utility Types
Utility types provided by Signality for working with signals, elements, and reactive values.
SignalValue<Type>
Extracts the value type from a Signal.
typescript
type SignalValue<S> = S extends Signal<infer V> ? V : never;MaybeSignal<Type>
Union type that accepts either a static value or a reactive Signal.
typescript
type MaybeSignal<T> = T | Signal<T>;MaybeElementSignal<Type>
Union type for element references that can be an element, ElementRef, or a Signal containing either of these (including null or undefined).
typescript
type MaybeElementSignal<T extends Element> =
| T
| ElementRef<T>
| Signal<T | ElementRef<T> | null | undefined>;Note: The signal variant includes
nullandundefinedbecause elements may dynamically change in reactive scenarios, particularly with conditional rendering where elements can appear or disappear based on signal values.
UnrefElement<Type>
Extracts the element type from ElementRef or returns the type as-is.
typescript
type UnrefElement<T> = T extends ElementRef<infer E> ? E : T;Related
- Key Concepts — Learn about Signal-First Design and common patterns
- Debounced — Uses
MaybeSignalfor debounce timing - ElementSize — Uses
MaybeElementSignalfor target elements