TypeScript: Setting string id to reference #1880
Answered
by
EmilTholin
sethdumaguin
asked this question in
Q&A
-
Hi there! I have an action in my model that takes in an Here's is a small snippet of what the structure of the code is below.
|
Beta Was this translation helpful? Give feedback.
Answered by
EmilTholin
Mar 1, 2022
Replies: 1 comment 1 reply
-
Hi @sethdumaguin! At this time you have to cast it to 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;
}
})); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
EmilTholin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @sethdumaguin!
At this time you have to cast it to
any
sadly, as outlined by xaviergonz here.