A WritableSignal<T> is an Angular signal whose stored value can be changed through writable operations. Read its current value by invoking it as a function, such as count(). The generic type describes the stored value, and TypeScript often infers it from the initial value. section 6.2.1
import { signal } from '@angular/core';
const count = signal(0);
A minimal signal declaration shows how an initial value creates a writable signal. section 6.2.1
Use WritableSignal<T> with these boundaries in mind:
- Provide the generic type when inference is ambiguous, such as signal<string[]>([]) for an empty string array. section 6.2.1
- Distinguish writable signals from Signal values: computed signals and signals created from observables are read-only because their values depend on other sources. section 6.2.1 section 6.6.1
- Expose a private writable signal as readonly when a service should control updates while consumers can only read its value. section 7.1.4
Filtering time-off requests
A time-off management component keeps selectedType as a writable signal, then derives filteredRequests and resolvedRequests with computed signals. The selection can be changed directly, while request data remains owned by its observable source. section 6.6.1
@Injectable({providedIn: 'root'})
export class SomeService {
readonly #data = signal<Data>({});
readonly data = this.#data.asReadonly();
}
A service pattern keeps mutation private and publishes a readonly view of the same signal. section 7.1.4

