Skip to content

TypeScript: Setting string id to reference #1880

Answered by EmilTholin
sethdumaguin asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @sethdumaguin!

At this time you have to cast it to any sadly, as outlined by xaviergonz here.

const Node = types.model({
  id: types.identifier
});

const RootStore = types
  .model({
    node: types.safeReference(Node)
  })
  .actions((self) => ({
    setNode: (id: string) => {
      self.node = id as any;
    }
  }));

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sethdumaguin
Comment options

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