xstate icon indicating copy to clipboard operation
xstate copied to clipboard

Deprecate `createModel(...)`

Open davidkpiano opened this issue 3 years ago • 4 comments

The createModel(...) function is now marked as deprecated, as it will be removed in XState version 5. It is recommended to use Typegen instead.

davidkpiano avatar Sep 18 '22 19:09 davidkpiano

🦋 Changeset detected

Latest commit: 771ca1f291029864d624eba0ce2faa075d34c5a0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
xstate Minor

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

changeset-bot[bot] avatar Sep 18 '22 19:09 changeset-bot[bot]

👇 Click on the image for a new way to code review
  • Make big changes easier — review code in small groups of related files

  • Know where to start — see the whole change at a glance

  • Take a code tour — explore the change with an interactive tour

  • Make comments and review — all fully sync’ed with github

    Try it now!

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map Legend

ghost avatar Sep 18 '22 19:09 ghost

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 771ca1f291029864d624eba0ce2faa075d34c5a0:

Sandbox Source
XState Example Template Configuration
XState React Template Configuration

codesandbox-ci[bot] avatar Sep 18 '22 19:09 codesandbox-ci[bot]

RIP createModel, you were a good experiment

with-heart avatar Sep 18 '22 19:09 with-heart

Oh no 🙊

farskid avatar Oct 29 '22 14:10 farskid

@davidkpiano Typegen has never been reliable for me, it can never cover all the userland requirements and sometimes it just doesn't work. image

Is there any other way to allow the typing that createModel allowed, it's a lot nicer than passing generics to the assign method and doesn't require reliance on an extension.

gkiely avatar Nov 06 '22 00:11 gkiely

@davidkpiano Typegen has never been reliable for me, it can never cover all the userland requirements and sometimes it just doesn't work. image

Is there any other way to allow the typing that createModel allowed, it's a lot nicer than passing generics to the assign method and doesn't require reliance on an extension.

What specific things are you using createModel for besides assign?

davidkpiano avatar Nov 06 '22 11:11 davidkpiano

Nothing outside of assign.

Usually actions with assigns, typically invoked. image

Example of what it looks like after the model: image image

gkiely avatar Nov 06 '22 15:11 gkiely

@davidkpiano After giving this some more thought, I've moved to using typescript narrowing which achieves the same thing. image

gkiely avatar Nov 08 '22 03:11 gkiely