Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): fix type ExtractStateValue to describe real state value #1409

Merged
merged 1 commit into from
Aug 25, 2020
Merged

fix(core): fix type ExtractStateValue to describe real state value #1409

merged 1 commit into from
Aug 25, 2020

Conversation

jirutka
Copy link
Contributor

@jirutka jirutka commented Aug 24, 2020

Consider the following schema:

type LightStateSchema = {
  states: {
    green: {},
    yellow: {},
    red: {
      states: {
        walk: {},
        wait: {},
        stop: {},
      },
    },
  },
}

The current implementation of the ExtractStateValue type generates the
following type:

{
  green?: {} | undefined
  yellow?: {} | undefined
  red?: "walk" | "wait" | "stop" | {
    walk?: {} | undefined
    wait?: {} | undefined
    stop?: {} | undefined
  } | undefined
}

This does not describe the StateValue of LightStateSchema as provided
in State.value.

The new implementation generates the following type:

"green" | "yellow" | "red" | {
  red?: "walk" | "wait" | "stop" | undefined
}

@changeset-bot
Copy link

changeset-bot bot commented Aug 24, 2020

🦋 Changeset is good to go

Latest commit: f51614d

We got this.

This PR includes changesets to release 7 packages
Name Type
xstate Minor
@xstate/analytics Major
@xstate/graph Major
@xstate/immer Major
@xstate/react Major
@xstate/test Major
@xstate/vue Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 24, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit f51614d:

Sandbox Source
XState Example Template Configuration
XState React Template Configuration

Consider the following schema:

    type LightStateSchema = {
      states: {
        green: {},
        yellow: {},
        red: {
          states: {
            walk: {},
            wait: {},
            stop: {},
          },
        },
      },
    }

The current implementation of the ExtractStateValue type generates the
following type:

    {
      green?: {} | undefined
      yellow?: {} | undefined
      red?: "walk" | "wait" | "stop" | {
        walk?: {} | undefined
        wait?: {} | undefined
        stop?: {} | undefined
      } | undefined
    }

This does not describe the StateValue of LightStateSchema as provided
in State.value.

The new implementation generates the following type:

    "green" | "yellow" | "red" | {
      red?: "walk" | "wait" | "stop" | undefined
    }
@davidkpiano davidkpiano merged commit 34a3097 into statelyai:master Aug 25, 2020
@github-actions github-actions bot mentioned this pull request Aug 25, 2020
@jirutka jirutka deleted the fix-extract-state-value branch November 25, 2020 16:23
@AliKholmatov
Copy link

image
Hi! In latest versions ExtractStateValue was deleted. What can I use instead of ExtractStateValue? Please)

@Andarist
Copy link
Member

Andarist commented Aug 1, 2022

Could you open a discussion that would describe your use case? For context, this type was removed in #2828 as we've assumed that it was a leftover from a previous implementation and that it wasn't used externally.

@AliKholmatov
Copy link

AliKholmatov commented Aug 1, 2022

@Andarist sorry I can't answer right now, I will try to figure out it. I guess it was used to make deal with TS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants