Skip to content

V5: Providing more specific types within implementation. #4574

Answered by Andarist
chaulkie asked this question in Q&A
Discussion options

You must be logged in to vote

Given the example above, how do we make sure that is correct and that it does use all of the required params (with correct types)?:

  on: {
    UPDATE: { actions: "evaluate" }
  },

I think this "call site" of the evaluate just stays unsound unless you configure the params types beforehand (in setup) or at the same time (in createMachine). TS just can't typecheck this based on the information that is provided later (in provide). If you want this kind of generic-ness then factory functions are the only way since it's the only way to make it work in TypeScript.

I see now that your example is using context.params (and not params that belong to an action). However, that doesn't change that muc…

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
6 replies
@chaulkie
Comment options

@Andarist
Comment options

@chaulkie
Comment options

@Andarist
Comment options

Answer selected by chaulkie
@chaulkie
Comment options

@tnortman
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants