Even safer solution, with read/write access and generated accessors! My example is for managing the front-end state of a Tauri app.
import { MyService } from './path/to/your/service';
// Access current state
const currentState = MyService.current;
// Update state
MyService.someProperty = newValue;
// Get snapshot
const stateSnapshot = MyService.snapshot;