Skip to content

Typescript Union of Reference & Model #1999

Discussion options

You must be logged in to vote

Hey @sethdumaguin - sorry it took so long for folks to get back to you.

I'm not precisely sure what's going on here, but I wonder if this is an issue where TypeScript can't appropriately infer the type from the types.reference call. I was able to remove the linting error by making these changes:

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

const Base = types.model("Base", { name: "" }).actions((self) => ({
  setName: (name: string) => {
    self.name = name;
  }
}));

const Foo = types.compose(
  "Foo",
  Base,
  types.model({
    type: "Foo"
  })
);

const Bar = types.compose(
  "Bar",
  Base,
  types.model({
    id: types.identifier,
    type: "Bar"
  })
);

const Tree = types
  .model("Tr…

Replies: 1 comment 1 reply

Comment options

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

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