Skip to content

[State Management] Transitions and selectors should know about state shape #54439

@Dosant

Description

@Dosant

Currently when creating state container, transition and selectors allow to have state shape mismatch and typescript doesn't complain:

createStateContainer(
  { test: "string" },
  {
   transition: (state: {otherShape: string}) => () => state
  }
);

Also have to specify state for each transition / selector explicitly, typescript doesn't infer it:

createStateContainer(
  { test: "string" },
  {
   transition: (state) => () => state // state is considered any here
  }
);

Where, if possible, it should be:

createStateContainer(
  { test: "hello" },
  {
   transition: (state) => () => state // typescript understands that state is {test: "string"} here and doesn't allows to assign anything else
  }
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature:StateManagementimpact:lowAddressing this issue will have a low level of impact on the quality/strength of our product.loe:smallSmall Level of Efforttechnical debtImprovement of the software architecture and operational architecture

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions