Dev Helpers
← Back

Create an initial state

Create an initial state using TypeScript.

Open this example in the interactive library

Source code

type State =
  | { phase: "idle" }
  | { phase: "loading"; id: number }
  | { phase: "ready"; text: string }
  | { phase: "error"; reason: string };
console.log({ phase: "idle" } satisfies State);

Sample output

{ phase: 'idle' }