Skip to content

snapshot <function> is not assignable to type: frozen #2271

Answered by coolsoftwaretyler
OnkelTem asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, this should actually work, you just need to do types.frozen<typeof Location>() instead. Although I wouldn't actually recommend doing it this way because you won't have access to any parameters you need. See:

import { types } from "mobx-state-tree";

const someFunction1 = () => {
  console.log("Hello, world");
};

const someFunction2 = () => {
  console.log("Goodbye, world");
};

const functionWithParam = (a: string) => {
  console.log(a);
};

export const SomeModel = types
  .model({
    name: types.string,
    func: types.frozen<typeof someFunction1>(someFunction1),
    funcWithParam: types.frozen<typeof functionWithParam>(functionWithParam),
  })
  .volatile(() => ({
    callback: s…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

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

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