xstate icon indicating copy to clipboard operation
xstate copied to clipboard

Bug: xState v5 getSnapshot value does not have a type

Open ShravanSunder opened this issue 2 years ago • 2 comments

Description

getSnapshot().value does not have a type

export interface StateValueMap {
  [key: string]: StateValue;
}

/**
 * The string or object representing the state value relative to the parent state node.
 *
 * - For a child atomic state node, this is a string, e.g., `"pending"`.
 * - For complex state nodes, this is an object, e.g., `{ success: "someChildState" }`.
 */
export type StateValue = string | StateValueMap;

The snapshot.matches() isn't typed because of this

Expected result

  • state should be typed based on MachineConfig states
  • matches should be typed based on MachineConfig states

Actual result

no types

Reproduction

n/a

Additional context

No response

ShravanSunder avatar Sep 10 '23 02:09 ShravanSunder

This might become possible once we land: https://github.com/statelyai/xstate/pull/4262

Andarist avatar Sep 10 '23 06:09 Andarist

#4498

davidkpiano avatar Nov 26 '23 18:11 davidkpiano