Skip to content

has some problem in Type Inference #773

Closed Answered by BenShelton
candy-Tong asked this question in Help and Questions
Discussion options

You must be logged in to vote

A few things you can try:

  1. The documentation for state says that type inference is more reliable when using an arrow function to define state, have you tried that? See https://pinia.esm.dev/core-concepts/state.html#state
  2. Instead of using shallowRef you can simply just define the state similar to the following and it'll still be reactive:
state: () => ({
  node: undefined as NodeConfig | undefined,
  edge: undefined as EdgeConfig | undefined
}),
  1. Within the action you can type cast the return value:
return this.edge as EdgeConfig | undefined

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@posva
Comment options

posva Nov 4, 2021
Maintainer

@candy-Tong
Comment options

Answer selected by posva
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #770 on November 04, 2021 15:35.