mobxjs / mobx-state-tree

Full-featured reactive state management without the boilerplate
https://mobx-state-tree.js.org/
MIT License
6.94k stars 641 forks source link

Intellisense not working with .named() models #1901

Closed gregbrinker closed 1 year ago

gregbrinker commented 2 years ago

Question

Hello! Relatively new to MST (<6 months). I have a type, let's call it TypeA. I also have a TypeB, which is a clone of TypeA with a few extra actions:

const TypeAModel = types.model("TypeA").props({
   prop1: types.string
})
.actions(
   action1()
)

const TypeBModel = TypeAModel.named("TypeB")
.actions(
   action2()
)

Let's say I have a functional component that has a prop called bModel: TypeBModel. In the component, hovering over bModel says it's of type any. When I type bModel., there aren't any autocomplete suggestions - action1(), action2(), or any of the props. The code runs fine, bModel.action1() calls the correct action as expected. But the autocomplete not working is just really annoying 😢 This doesn't happen to TypeAModel though, Intellisense can pick up on those just fine.

If anyone knows how to solve this, it would be much appreciated!

coolsoftwaretyler commented 1 year ago

Hey @gregbrinker - I'm really sorry it took so long for anyone to get back to you here. I'm curious if you're still having this problem. If so, can you provide more information about your Intellisense setup? My VS Code seems to autofill things correctly with the code snippet you wrote:

Screenshot 2023-06-25 at 10 34 34 PM

I'm going to tag this as needs more info for now, and again, sorry it took so long!

coolsoftwaretyler commented 1 year ago

Closin' out. Sorry we didn't help ya when it was more relevant!