Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

got 「unknown」 type when using Instance<typeof SomeModel> #2217

Open
3 tasks done
JLUiceman opened this issue Oct 22, 2024 · 7 comments
Open
3 tasks done

got 「unknown」 type when using Instance<typeof SomeModel> #2217

JLUiceman opened this issue Oct 22, 2024 · 7 comments
Labels
docs or examples Documentation or examples related Typescript Issue related to Typescript typings

Comments

@JLUiceman
Copy link

Bug report

  • I've checked documentation and searched for existing issues and discussions
  • I've made sure my project is based on the latest MST version
  • Fork this code sandbox or another minimal reproduction.

Sandbox link or minimal reproduction code
I try to get the type of model by using Instance method just like the doc recommended, but the result confused me:

when i define a model like the pic below, it works fine
截屏2024-10-22 15 27 30

but when i define a model in this way, i got a unknown type
截屏2024-10-22 15 22 14

Is there anyway i can avoid this or i just missed some key information when reading the doc?

@thegedge
Copy link
Collaborator

@JLUiceman are you on the latest version? I wasn't able to reproduce :(

CleanShot 2024-10-22 at 09 44 39@2x

@thegedge thegedge added the Typescript Issue related to Typescript typings label Oct 22, 2024
@kuguarpwnz
Copy link

type resolution does not work for me in WebStorm
image

although it works in vs code
image

@JLUiceman
Copy link
Author

@JLUiceman are you on the latest version? I wasn't able to reproduce :(

CleanShot 2024-10-22 at 09 44 39@2x

@thegedge Thanks for reply! Yes, project's current mst version is 6.0.1;
@kuguarpwnz kuguarpwnz's comment inspired me; I tried to run the same code in VSCode, and it works fine :). I'm curious why there is such a difference.

@thegedge
Copy link
Collaborator

Great question!

If I had to guess, it's one of three things:

  1. A language server other than tsserver that's behaving differently.
  2. The language server not properly loading up tsconfig.
  3. Wrong version of typescript is evaluating things inside the language server.

@thegedge thegedge added the docs or examples Documentation or examples related label Oct 23, 2024
@thegedge
Copy link
Collaborator

thegedge commented Oct 23, 2024

That being said, I'll flag this as a perhaps a small docs update where we could have a callout for issues with types when using WebStorm. If you do figure out what the issue is, though, drop a comment here :)

@JLUiceman
Copy link
Author

That being said, I'll flag this as a perhaps a small docs update where we could have a callout for issues with types when using WebStorm. If you do figure out what the issue is, though, drop a comment here :)

Yep, I will also continue to follow up on this issue and try to find out the possible reasons. If there are further conclusions, I will comment here.
Thanks for your patient explanation, and hope we can got a solution:)

@jaryway
Copy link

jaryway commented Oct 31, 2024

image
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs or examples Documentation or examples related Typescript Issue related to Typescript typings
Projects
None yet
Development

No branches or pull requests

4 participants